From patchwork Tue Feb 4 14:25:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 11364727 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7FB7314B4 for ; Tue, 4 Feb 2020 14:25:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 567EE20730 for ; Tue, 4 Feb 2020 14:25:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 567EE20730 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 76D026B0010; Tue, 4 Feb 2020 09:25:24 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org 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-Original-To: linux-mm@kvack.org 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-Spam-Summary: 1,0,0,,d41d8cd98f00b204,jack@suse.cz,:willy@infradead.org:linux-fsdevel@vger.kernel.org::jack@suse.cz,RULES_HIT:30034:30051:30054:30090,0,RBL:195.135.220.15:@suse.cz:.lbl8.mailshell.net-62.2.6.2 64.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none 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));