From patchwork Fri Sep 15 18:38:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13387467 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 DCC71EED61E for ; Fri, 15 Sep 2023 18:39:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0DD36B03B9; Fri, 15 Sep 2023 14:39:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB99E6B03BA; Fri, 15 Sep 2023 14:39:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE6976B03BB; Fri, 15 Sep 2023 14:39:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AEAFA6B03B9 for ; Fri, 15 Sep 2023 14:39:13 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8F0FD1604EF for ; Fri, 15 Sep 2023 18:39:13 +0000 (UTC) X-FDA: 81239694186.30.C15D3A2 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf20.hostedemail.com (Postfix) with ESMTP id D4A7C1C0022 for ; Fri, 15 Sep 2023 18:39:11 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="j/WoRm7k"; spf=pass (imf20.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803152; 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:in-reply-to:references:references:dkim-signature; bh=2grCxcqK8FKtyCgTOlZ0MTRPcri5sYlchrmngCOgl8U=; b=pQquoK+ntUhkKwk4UvDa6/R7qcEzHXq69f9t7UkDatFJWgocE+Qp+iJTDOs9gVUYktfQoi FnJ0MVye1EIxDrVTNl07BVf/gk26QCvTGY+kXmbApmLe23I2t8uik5YLgWhMf+IFQ4Ym6R IBBbqK6QuVNU/zJO9yYY3O+E2dgXMCE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803152; a=rsa-sha256; cv=none; b=1ez57ALXuH9txYOeX+pDEdr9NlE1tFsFCrPi+iTc51Y2dUyN+a3zJ9mWrND+P4RhHnQktS dYaC2a3taX0xWITh+prBGXFMMNKyftcbSsEs1UgKlE7sLvcMOZUG+iSJxoGIVUj/DlxB1k Kh4Ir3R6fNV95CiFlayAlR0Dx0ih+v8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="j/WoRm7k"; spf=pass (imf20.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4RnNJD57K5z9sW2; Fri, 15 Sep 2023 20:39:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803148; 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: in-reply-to:in-reply-to:references:references; bh=2grCxcqK8FKtyCgTOlZ0MTRPcri5sYlchrmngCOgl8U=; b=j/WoRm7kqZ2NoZ5OjDxKOQdGsBPUtApoPN7xyVBhTkrQsnhPqztuwiVWc2+UMXFhXmucnn yV+5CVecVrEDZ/RgmtLrE4lsA0aMvZFUc6TXMrY/E0TUv11fr40etSwDNW4JstoTE3PGdc wzKsqHxrr54nqKGxraGFN5jT4guAQfbru8I95DPokA3ewiwi5qz50a3aIhjBlV9pFFIWnV /3j3RMZ/xhGVgtsWXbHphYwPMEotMMqn+UED9KX4/9IgzyhYXmjjJeptgYB1o9oG1BDw5K SfyVH8Havcutw80kiMU8+RDv5/rYTA2MFLmQBkfN08ZgPi5O8qpzk1LIGJ1oUw== From: Pankaj Raghav To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: p.raghav@samsung.com, david@fromorbit.com, da.gomez@samsung.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, willy@infradead.org, djwong@kernel.org, linux-mm@kvack.org, chandan.babu@oracle.com, mcgrof@kernel.org, gost.dev@samsung.com Subject: [RFC 06/23] mm: call xas_set_order() in replace_page_cache_folio() Date: Fri, 15 Sep 2023 20:38:31 +0200 Message-Id: <20230915183848.1018717-7-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: D4A7C1C0022 X-Rspam-User: X-Stat-Signature: 6zbiq1hth9f6wsxfrpxxecf6xoogtja1 X-Rspamd-Server: rspam03 X-HE-Tag: 1694803151-313170 X-HE-Meta: U2FsdGVkX18cWggy3e8P85JTBCIEOCvdHKHmRcUf5XkgTEPFI8iLbvmY0+5NLRmCt25INERvHiHLeageN8lxmHNGtIoJ8bDqr91NmdpWb2dfr+IkvM46oS2xaAiEZmBUg5pgGIRCPMRFafegEqyoq2G3Tan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tX+lbNwu6EvyQGvJ01MUchjbXNnFKMIEEwd6B7Y8Bg2qfTqqVmIfL3wujl2qFmXhxYVkgGNyhWs/zXGF6mk3bQMEqOZ/BQhNv1qbY4GXxXSyl67y9bn54DC44gkvfwJVgEj8AxvLaehDaSh8CTv5IKtIwkSYQ= 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: From: Luis Chamberlain Call xas_set_order() in replace_page_cache_folio() for non hugetlb pages. Signed-off-by: Luis Chamberlain --- mm/filemap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 4dee24b5b61c..33de71bfa953 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -815,12 +815,14 @@ EXPORT_SYMBOL(file_write_and_wait_range); void replace_page_cache_folio(struct folio *old, struct folio *new) { struct address_space *mapping = old->mapping; + unsigned int min_order = mapping_min_folio_order(mapping); void (*free_folio)(struct folio *) = mapping->a_ops->free_folio; pgoff_t offset = old->index; XA_STATE(xas, &mapping->i_pages, offset); VM_BUG_ON_FOLIO(!folio_test_locked(old), old); VM_BUG_ON_FOLIO(!folio_test_locked(new), new); + VM_BUG_ON_FOLIO(folio_order(new) != folio_order(old), new); VM_BUG_ON_FOLIO(new->mapping, new); folio_get(new); @@ -829,6 +831,11 @@ void replace_page_cache_folio(struct folio *old, struct folio *new) mem_cgroup_migrate(old, new); + if (!folio_test_hugetlb(new)) { + VM_BUG_ON_FOLIO(folio_order(new) < min_order, new); + xas_set_order(&xas, offset, folio_order(new)); + } + xas_lock_irq(&xas); xas_store(&xas, new);