|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2] gnttab: defer allocation of status frame tracking array
Hi Jan, On 04/01/2021 13:37, Jan Beulich wrote: On 24.12.2020 10:57, Julien Grall wrote:Hi Jan, On 23/12/2020 15:13, Jan Beulich wrote: I am not arguing on whether this is a sensible thing to do but how someone else can make use of it. The common lockless pattern to access the array would be checking the count and if it is not zero, then access the array. Imagine the following:
CPU0 (free the array) | CPU1 (access the array)
|
| if ( !gt->nr_status_frames )
gt->nr_status_frames = 0; | return;
smp_wmb(); |
gt->status = NULL; |
| smp_rmb();
| access gt->status[X];
Without any lock (or refcounting), I can't see how the example above
would be safe.
The allocation and free cannot happen locklessly (at least in the current state). For the consumers see above.Subsequently allocation and consumers could be updated to follow suit ... So I would drop the barrier here.I certainly can (unless double checking would tell me otherwise), but I'm not convinced this is a good idea. I'd rather have a barrier too many in the code than one too little, even if the "too little" may only be the result of a future change. Future-proof code is always good to have. However, we need to avoid adding barriers that doesn't seem to usuable either today or in the future. Your in-code comment suggests the barrier would help when the array is access without any lock. However, I can't see how this hypothetical code would work. Can you provide an example how you can deal with memory freed behind your back? And this isn't a path where performance considerations would suggest avoiding barriers when they're not strictly needed. I am not concerned about the performance here. Cheers, -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |