From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A709C47409 for ; Tue, 4 Feb 2020 14:25:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0536520730 for ; Tue, 4 Feb 2020 14:25:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0536520730 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7E3C16B000E; Tue, 4 Feb 2020 09:25:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 76D026B0010; Tue, 4 Feb 2020 09:25:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6ABB56B0266; Tue, 4 Feb 2020 09:25:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4AE2E6B000E for ; Tue, 4 Feb 2020 09:25:24 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 06682181AC9BF for ; Tue, 4 Feb 2020 14:25:24 +0000 (UTC) X-FDA: 76452667368.08.toy27_2f1b2a395c110 X-HE-Tag: toy27_2f1b2a395c110 X-Filterd-Recvd-Size: 2518 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Tue, 4 Feb 2020 14:25:23 +0000 (UTC) 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 B4E16ACF0; Tue, 4 Feb 2020 14:25:22 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 0F8351E0D1A; Tue, 4 Feb 2020 15:25:16 +0100 (CET) From: Jan Kara To: Matthew Wilcox Cc: , , Jan Kara Subject: [PATCH 8/8] xarray: Don't clear marks in xas_store() Date: Tue, 4 Feb 2020 15:25:14 +0100 Message-Id: <20200204142514.15826-9-jack@suse.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200204142514.15826-1-jack@suse.cz> References: <20200204142514.15826-1-jack@suse.cz> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When storing NULL in xarray, xas_store() has been clearing all marks because it could otherwise confuse xas_for_each_marked(). That is however no longer true and no current user relies on this behavior. Furthermore it seems as a cleaner API to not do clearing behind caller's back in case we store NULL. This provides a nice boost to truncate numbers due to saving unnecessary tag initialization when clearing shadow entries. Sample benchmark showing time to truncate 128 files 1GB each on machine with 64GB of RAM (so about half of entries are shadow entries): AVG STDDEV Vanilla 4.825s 0.036 Patched 4.516s 0.014 So we can see about 6% reduction in overall truncate time. Signed-off-by: Jan Kara --- lib/xarray.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/xarray.c b/lib/xarray.c index 4e32497c51bd..f165e83652f1 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -799,17 +799,8 @@ void *xas_store(struct xa_state *xas, void *entry) if (xas->xa_sibs) xas_squash_marks(xas); } - if (!entry) - xas_init_marks(xas); for (;;) { - /* - * Must clear the marks before setting the entry to NULL, - * otherwise xas_for_each_marked may find a NULL entry and - * stop early. rcu_assign_pointer contains a release barrier - * so the mark clearing will appear to happen before the - * entry is set to NULL. - */ rcu_assign_pointer(*slot, entry); if (xa_is_node(next) && (!node || node->shift)) xas_free_nodes(xas, xa_to_node(next)); -- 2.16.4