Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp797516ybz; Wed, 22 Apr 2020 08:10:55 -0700 (PDT) X-Google-Smtp-Source: APiQypL3h1+mAHuye/9AcZzxP5hEX/OuQIYBgqmbmLB11B8I/7jDrZMCI/ZvODgOkP/JtUZgDwjo X-Received: by 2002:aa7:dd53:: with SMTP id o19mr22872463edw.180.1587568255821; Wed, 22 Apr 2020 08:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587568255; cv=none; d=google.com; s=arc-20160816; b=FMAkctFzAC21kVUpvrM0iF533Zow+c7fs4HirpXoMXF4WChF6bwUKW5A1hBh4OPj9g Z1d2MRaCJgXCaU93LzuIk4eQsBd1yoNbWbbXWmWfjEenJkuKUhcNcUhGyXMF5IZb62c4 7TF02ob9sbTdSH1luNn4C7uOwr7p+4MwgVwZUMF9VdZtg4HkKBZOzK+IEk+J50BJdih7 3y35qDdtPshJoobcPXKZizQnnM+eW3Pc3MLBE2BixuWf0b3BVhrevveVn38/dYId1qYH 5UKMMqbCCM/m/uhUwTizwBm86sDYRl3iAkb1Mm8GTd4AG0VEGzxW//zhWhoWOtcT9i7k biTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=e8GWvw5IAGntbNq0VY/M7UlVlci0/8MSm92V2igoJvA=; b=k+kLAKHolk3S3COvzcLXGxia2xWSq7YyTGRDlMOLx8jtBP9joCVSVpfIKrR9VSj53K ar1P0OkGIL7Vs4PKZqEMIT9dUre+kuu7fieyy2EJl4MDv91c3yAhxd3Psf+BnEfFeZkT Jxphaczsw3WUCJ1LvFgY0+dX7wyc8IKHmMb6t5q3hOiSmO9sCj4ZwQdl7eLrg3iN43QR vRc5hwjEQhREhx3HKSfTR8DseRZH3I1l+b71DKJAYgsvZosvpCPKUIY6CA/cjruAEoJj ILazFIFd182Vc6MmPzO7C4WNidSLbVbJ4zyFIhhxSXsCK2HWyZdcqt1NKE9PsFslQtr4 8XGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id me7si3991164ejb.191.2020.04.22.08.10.21; Wed, 22 Apr 2020 08:10:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726138AbgDVPFn (ORCPT + 99 others); Wed, 22 Apr 2020 11:05:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:58096 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728055AbgDVPDH (ORCPT ); Wed, 22 Apr 2020 11:03:07 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 59AF3AD26; Wed, 22 Apr 2020 15:03:03 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 7313E1E0E83; Wed, 22 Apr 2020 17:03:03 +0200 (CEST) From: Jan Kara To: Matthew Wilcox Cc: , LKML , Jan Kara Subject: [PATCH 07/23] xarray: Switch __xa_cmpxchg() to use xas_store_noinit() Date: Wed, 22 Apr 2020 17:02:40 +0200 Message-Id: <20200422150256.23473-8-jack@suse.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200422150256.23473-1-jack@suse.cz> References: <20200422150256.23473-1-jack@suse.cz> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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