Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5011528rdb; Fri, 15 Sep 2023 22:17:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0fnwW9Tor5eRJkBSOENWR7JANoHrPB47fLoLAgGS8z0Zny1Sb7j3+X47M2KI++oIivkaB X-Received: by 2002:a05:6a00:1704:b0:68f:d44c:22f8 with SMTP id h4-20020a056a00170400b0068fd44c22f8mr4876607pfc.1.1694841428897; Fri, 15 Sep 2023 22:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694841428; cv=none; d=google.com; s=arc-20160816; b=OyQ6m90jXZ7x/fblhH559MpEnVB2MaX5N+j+sxJqycmw3ygh0kDjMNq4S1SprWB4v8 9fRcMZkEWO3Qj8dlU+NqVwSCFCutw9nTVDAyV0G3lfJ3ix4C1IG4n5w89hC0hh4KypBP fjs5t0sVyZENbuIFJklQGO/kMg3LLZDJRu89FvKVzG3+KBsM+j5grNUAVdMFrn9MwgqM ZR4s+VQdfACp1GI/ijc95d7J2uzgWRjub28A5ePDh/hBVxWDhFrjajLMukTf9WTeRAug 3o33YvktE4M9I9EDzTUYxZ2v//NgKwgV3IOaL9uWLdOuoJrSKi5G3WqpKZUbZzjz2BZp zVjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vFsIs+qRJRSVkUkhUlyZ9H4Jh3BsQexeaTYNPM7knQw=; fh=kl+S4GAUWD1kOeoqBopscteh2mu3DZslcHc01dOJ6TI=; b=ZxWqcXp23gMKO33/sb/LmnVzAccoHoMcogNhoAUBvo/QIGyScre2zhgXgJi5wix9Sq KknCciCcGVT4q1vTY7+B+SO3Jwza6tWAAIwLex3oigT7GkZ7B+GDNDSuWv9Nr+ySYHVs IrqDNneMckk1A5zx1OjI+3i0mGiDBrDhR/wijgH81r5MhxTkf2l0qiWsDvL3REi2hcke wYBHzVwWPkD60hKCPgveBdYKbWT5i20YMrImSaEMJWEezduaRKrWMtV3n0YA5CtReG0r liYvZ3ztv9Q7I11bJVTeTu6M74dvQIZL/FTTlkxszg+HaOobeCeETG06PW++ndEOHwLe 5iBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=hVgB1L3L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o9-20020a056a001bc900b0068e4704fd5bsi4368004pfw.346.2023.09.15.22.17.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 22:17:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=hVgB1L3L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CD0A083A7BFB; Fri, 15 Sep 2023 11:43:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236889AbjIOSmh (ORCPT + 99 others); Fri, 15 Sep 2023 14:42:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236964AbjIOSmP (ORCPT ); Fri, 15 Sep 2023 14:42:15 -0400 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57E86469F; Fri, 15 Sep 2023 11:39:07 -0700 (PDT) Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (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-103.mailbox.org (Postfix) with ESMTPS id 4RnNJ73F62z9spF; Fri, 15 Sep 2023 20:39:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803143; 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=vFsIs+qRJRSVkUkhUlyZ9H4Jh3BsQexeaTYNPM7knQw=; b=hVgB1L3L+hfbOFs9pzt7JSZ0hL75va+f5dGTqbKq35/LHth7vuCtJyolpUYaCtZSdpXEix JXkNguxLkbblJKEYeBRWw4sugGoImquURo+WUPFARno3LgpZs20LLYLTi+D1WoWj+VLGNq uk+eLY+KxGkhRGjoDU09147fIC6cq8HBY7YH1MqbB89sTKYaddEmbOywPuL2wAm0HAG1d7 uT6Hp9zxX7OT0WFkFyl90rEJTT/PqBgWimlkD0UmghcqOvuwIJ8F+Ojn/orHfim//bDchH UtjJ+Oczct31qILqny72oU57MW1XThTi8wVKz646qcGe6HdWO6Pw8qfKMm7E8Q== 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 04/23] filemap: set the order of the index in page_cache_delete_batch() Date: Fri, 15 Sep 2023 20:38:29 +0200 Message-Id: <20230915183848.1018717-5-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 15 Sep 2023 11:43:02 -0700 (PDT) From: Luis Chamberlain Similar to page_cache_delete(), call xas_set_order for non-hugetlb pages while deleting an entry from the page cache. Also put BUG_ON if the order of the folio is less than the mapping min_order. Signed-off-by: Luis Chamberlain --- mm/filemap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index b1ce63143df5..2c47729dc8b0 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -126,6 +126,7 @@ static void page_cache_delete(struct address_space *mapping, struct folio *folio, void *shadow) { + unsigned int min_order = mapping_min_folio_order(mapping); XA_STATE(xas, &mapping->i_pages, folio->index); long nr = 1; @@ -134,6 +135,7 @@ static void page_cache_delete(struct address_space *mapping, xas_set_order(&xas, folio->index, folio_order(folio)); nr = folio_nr_pages(folio); + VM_BUG_ON_FOLIO(folio_order(folio) < min_order, folio); VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); xas_store(&xas, shadow); @@ -276,6 +278,7 @@ void filemap_remove_folio(struct folio *folio) static void page_cache_delete_batch(struct address_space *mapping, struct folio_batch *fbatch) { + unsigned int min_order = mapping_min_folio_order(mapping); XA_STATE(xas, &mapping->i_pages, fbatch->folios[0]->index); long total_pages = 0; int i = 0; @@ -304,6 +307,11 @@ static void page_cache_delete_batch(struct address_space *mapping, WARN_ON_ONCE(!folio_test_locked(folio)); + /* hugetlb pages are represented by a single entry in the xarray */ + if (!folio_test_hugetlb(folio)) { + VM_BUG_ON_FOLIO(folio_order(folio) < min_order, folio); + xas_set_order(&xas, folio->index, folio_order(folio)); + } folio->mapping = NULL; /* Leave folio->index set: truncation lookup relies on it */ -- 2.40.1