From patchwork Wed Oct 2 22:51:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 13820515 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F241FCF8546 for ; Wed, 2 Oct 2024 22:52:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 312576B04F5; Wed, 2 Oct 2024 18:52:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C2F36B04F6; Wed, 2 Oct 2024 18:52:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B1046B04F7; Wed, 2 Oct 2024 18:52:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E3AC46B04F5 for ; Wed, 2 Oct 2024 18:52:16 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4D994A9CC5 for ; Wed, 2 Oct 2024 22:52:16 +0000 (UTC) X-FDA: 82630162272.20.FFADE4A Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) by imf09.hostedemail.com (Postfix) with ESMTP id 895D3140003 for ; Wed, 2 Oct 2024 22:52:14 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=QqsHM7qm; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf09.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.185 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727909393; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=U8tOymQHHimVq3zwKDo6/iE7zqCLLuxcCMIxrRyJdq8=; b=RAfo6YW8E1Xwt4kjO0oAykXtE10QuxgaYMHv5cef7Bwr+FzixkCMu+xe4/w3UfQMJzze56 hR0VDQmAQhfBj2xeHdXEkjnMCDFNg16zfEbiHSSxAovs3k68n+WQp8akugfX61J344aR99 AdgyssAYN0+E6GXdInYOPkVy1WROpw0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727909393; a=rsa-sha256; cv=none; b=7OVEMcPwRVrvCOpPDsBmSQJW9fs49BIzbDUexTUTMvOvErOT3QduvaVnW8QpzisqKRm2mA p9uNcgbBZGbyHdNVVOn4NxispKKfiuJVzlw1XVys1DLIRIz+siVx8L7BYwrcNhH7DDpu0J HIjrY19/e5oS6WeaX5y2fe323+riiiA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=QqsHM7qm; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf09.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.185 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1727909532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=U8tOymQHHimVq3zwKDo6/iE7zqCLLuxcCMIxrRyJdq8=; b=QqsHM7qmlPxirfm91ti94oBUtzRUZYLH/7/BYyHom1785iMRjasFUbepgpkcpn0dYCIl8U ffk1M4+9vdbwTGftWLndO+D8P6X2/l/TB2jwqqbTteVs8fCy4zbdOT+4J2fQmMnrb9OM8n mgLFgQmlJgx4CSAEfQnKDZ0No+o3Qi0= From: Shakeel Butt To: Andrew Morton Cc: Johannes Weiner , Matthew Wilcox , Yu Zhao , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Meta kernel team Subject: [PATCH] mm/truncate: reset xa_has_values flag on each iteration Date: Wed, 2 Oct 2024 15:51:50 -0700 Message-ID: <20241002225150.2334504-1-shakeel.butt@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 895D3140003 X-Stat-Signature: jgj9s1iicpmfonwc9h3einwmogdk13fx X-Rspam-User: X-HE-Tag: 1727909534-337471 X-HE-Meta: U2FsdGVkX1+V722vDFdv0yOfzLsEwrB2UeQfVfBa6bgF9RQqwwqRnmH1GTP0pxeB9Yov+eNbwGAx2h/HJvY/xWwQ+ExQYBtp54/7kDukjx/Fdf/xN9TPODFjbqZ/GKFkQ19OYNSeJ7FKuSd4QrKb13gWRgmXvT50CksygY+5JLg6hGdnJHKNjZf2IXzT3jepY3F46FPh94fs2Ml4vwApYdi6c8TY823Reb5CSeX1Ujpd5ayXXUTEQE05HsdFg4pJDtmg4sn5X7ZlVHvgLxsw3+KUkfOAtjMlm3tHN7oHbzXUu2Qfv5br7mwpdzvYIlk6f/rPQ7KlkwCkoeqWjGQOC+PiVFzWNxD2U3zX/P0zyIti+jgUKaK5INErNfn6Fkps0/LXku3Du8BA2qNJ+zJ+Inp8QKnEcx4CUYikpNhnV+GPBvs2ADEHjQViARLFaOOIZrokN0iuMw8jpWDgforl46iI6qyxJ0o6UrR9STuGZHuaTGDh6spCOCQ+nz8tC1i5myz6TDRSV6ylg6WEtjZcriOqdeBqtlBWtOkO7UAiHNhUFWlXmdKcA3BGmTXcC+7M7KgJvRU8zCrvgldpNltKyezX+VHz3tWX0hid5mQxWnKFpiaMUhQb+H2jqnzVY4tN8Orj1h89owGIuKTNMMT6TSVE0m82q7Y02aBC66s3oKi4MyXOAwOcjw+i/8isS0CIIhUWT4zpJmLej91pSKD0zBdj6vUTQI0ROKXhIjId8E9Me/arqOb1zYPKS3dyKJbKFkoQrdrGwVl3Pz/qRF/gCfvn0Bdo5uHu8rrCX6qVte1lRpZWkTcxz2utp7JWAawgFyd73wvzirkmtQp2f2NTnw/MsXtUIinpryjRz1sFg7WEg8ajOtujlAn12v/w8sZRoXe+KERsYpJf5Gfx3SYAOGXOrPcwiho3LAFq4F0jc6y1kLb1jGrUiazKwEqL5AbV3Biy5J23m2teOS8N4SQ ukpe2cJv RTO0NpjONMDaShqhkiXu+XvUcQIo8QV67LaejvXUrFCCn49QBWeBqR6kvrzn8tMCfvGygsgaE9fFJ649wfI1xSNDKe85PchMkBYRi4x1GhoreoZNdj+Tb6Zdx7Zh3wGubWvoDYfUrIps7iMmLu+mEiOJKtK8uAjdWF+yxni8D/o7HndoNCrvM7fUZ6A== 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: List-Subscribe: List-Unsubscribe: Currently mapping_try_invalidate() and invalidate_inode_pages2_range() traverses the xarray in batches and then for each batch, maintains and set the flag named xa_has_values if the batch has a shadow entry to clear the entries at the end of the iteration. However they forgot to reset the flag at the end of the iteration which cause them to always try to clear the shadow entries in the subsequent iterations where there might not be any shadow entries. Fixing it. Fixes: 61c663e020d2 ("mm/truncate: batch-clear shadow entries") Signed-off-by: Shakeel Butt Acked-by: Yu Zhao --- mm/truncate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/truncate.c b/mm/truncate.c index 520c8cf8f58f..e5151703ba04 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -463,10 +463,10 @@ unsigned long mapping_try_invalidate(struct address_space *mapping, unsigned long ret; unsigned long count = 0; int i; - bool xa_has_values = false; folio_batch_init(&fbatch); while (find_lock_entries(mapping, &index, end, &fbatch, indices)) { + bool xa_has_values = false; int nr = folio_batch_count(&fbatch); for (i = 0; i < nr; i++) { @@ -592,7 +592,6 @@ int invalidate_inode_pages2_range(struct address_space *mapping, int ret = 0; int ret2 = 0; int did_range_unmap = 0; - bool xa_has_values = false; if (mapping_empty(mapping)) return 0; @@ -600,6 +599,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping, folio_batch_init(&fbatch); index = start; while (find_get_entries(mapping, &index, end, &fbatch, indices)) { + bool xa_has_values = false; int nr = folio_batch_count(&fbatch); for (i = 0; i < nr; i++) {