lkml.org 
[lkml]   [2020]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 07/23] xarray: Switch __xa_cmpxchg() to use xas_store_noinit()
    Date
    Currently there are four places that end up calling into __xa_cmpxchg().
    Two in drivers/infiniband/hw/mlx5/odp.c, one in fs/erofs/utils.c and one
    in mm/shmem.c. The xarray in the first three places do not contain any
    marks ever, the fourth place originally used radix_tree_delete_item()
    which didn't touch marks either. So we are safe to switch __xa_cmpxchg()
    to use xas_store_noinit(). Also document that __xa_cmpxchg() now does
    not touch marks at all - i.e., it has ordinary store semantics without
    specialcasing NULL value. If someone ever needs xa_cmpxchg() equivalent
    that would really cause mark clearing on storing NULL, we can create
    xa_erase_item() function.

    Signed-off-by: Jan Kara <jack@suse.cz>
    ---
    lib/xarray.c | 5 +++--
    1 file changed, 3 insertions(+), 2 deletions(-)

    diff --git a/lib/xarray.c b/lib/xarray.c
    index a372c59e3914..d87045d120ad 100644
    --- a/lib/xarray.c
    +++ b/lib/xarray.c
    @@ -1460,7 +1460,8 @@ EXPORT_SYMBOL(xa_store);
    *
    * You must already be holding the xa_lock when calling this function.
    * It will drop the lock if needed to allocate memory, and then reacquire
    - * it afterwards.
    + * it afterwards. The call does not change any xarray marks except for
    + * XA_FREE_MARK if free tracking is enabled.
    *
    * Context: Any context. Expects xa_lock to be held on entry. May
    * release and reacquire xa_lock if @gfp flags permit.
    @@ -1478,7 +1479,7 @@ void *__xa_cmpxchg(struct xarray *xa, unsigned long index,
    do {
    curr = xas_load(&xas);
    if (curr == old) {
    - xas_store(&xas, entry);
    + xas_store_noinit(&xas, entry);
    if (xa_track_free(xa)) {
    if (entry && !curr)
    xas_clear_mark(&xas, XA_FREE_MARK);
    --
    2.16.4
    \
     
     \ /
      Last update: 2020-04-22 17:06    [W:3.033 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site