From patchwork Fri Nov 1 15:50:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13858789 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 654B41531E3; Fri, 1 Nov 2024 06:51:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730443882; cv=none; b=b48hTtHxFFn/TJRQ4p+pI6PQki5fw7QGkqoOZxs5MdUDF4TwVDkXQDTZWUCQV/sOKHESmtgWb2m2+Dua/ZHhNCuOgjfI7nNA9TNdEfm/7eGWtVu35QTFnwwdQ/PjaPqWzj6QejFenLRDYy6kFH7dSZPWztnVRCGX6P0XIdv8xsg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730443882; c=relaxed/simple; bh=flwSYDcWTypdwkLTK0g+BKXw2vEs+2Y5lrs2u3gyT+I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HpJ9dFn/mCF6CQjMelN5IEZ1sGShcSsAUmlMMyWtGIKL7HYhgNfZd8rq4IHAM4glDv1QYe5ydCmnjgUmw40Cxa7qxKBPPryXPMfaTmFrRIA9uzN2cNKxkxT/7OwX29Y6eRuZ4PoiR6unDq1O8o74Z4pqEuEmJfRPWprV4zCwipA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Xfs2N2gdyz4f3mHK; Fri, 1 Nov 2024 14:50:52 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id 0249B1A018D; Fri, 1 Nov 2024 14:51:11 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP3 (Coremail) with SMTP id _Ch0CgAHmcVceiRnzhcPAg--.62749S6; Fri, 01 Nov 2024 14:51:10 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, willy@infradead.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 4/6] Xarray: skip unneeded xas_store() and xas_clear_mark() in __xa_alloc() Date: Fri, 1 Nov 2024 23:50:26 +0800 Message-Id: <20241101155028.11702-5-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20241101155028.11702-1-shikemeng@huaweicloud.com> References: <20241101155028.11702-1-shikemeng@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgAHmcVceiRnzhcPAg--.62749S6 X-Coremail-Antispam: 1UD129KBjvdXoWruFW8tFyrKr45tw17AFW5Wrg_yoWfWFg_Aa 4vqr9rJw4DKF92q3Wa9rsYvryrArs0krWruFWDtF9ruF4DJrZxC34vyrn8Xas09F4jkFy7 Jrs8ur1jkr1IqjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbS8YFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l87I20VAvwVAaII0Ic2I_JFv_Gryl82 xGYIkIc2x26280x7IE14v26r126s0DM28IrcIa0xkI8VCY1x0267AKxVW8JVW5JwA2ocxC 64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM2 8EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq 3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8w Aqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE 14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x 0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E 7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcV C0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF 04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7 CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jyYLPUUUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ If xas_find_marked() failed, there is no need to call xas_store() and xas_clear_mark(). Just call xas_store() and xas_clear_mark() if xas_find_marked() succeed. Signed-off-by: Kemeng Shi --- lib/xarray.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/xarray.c b/lib/xarray.c index 3fac3f2cea9d..012d0ef5e847 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -1860,10 +1860,11 @@ int __xa_alloc(struct xarray *xa, u32 *id, void *entry, xas_find_marked(&xas, limit.max, XA_FREE_MARK); if (xas.xa_node == XAS_RESTART) xas_set_err(&xas, -EBUSY); - else + else { *id = xas.xa_index; - xas_store(&xas, entry); - xas_clear_mark(&xas, XA_FREE_MARK); + xas_store(&xas, entry); + xas_clear_mark(&xas, XA_FREE_MARK); + } } while (__xas_nomem(&xas, gfp)); return xas_error(&xas);