From patchwork Fri Sep 15 18:38:45 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: 13387481 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 5B63BEED61F for ; Fri, 15 Sep 2023 18:40:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D0886B03D5; Fri, 15 Sep 2023 14:39:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9030B6B03D7; Fri, 15 Sep 2023 14:39:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 779146B03D8; Fri, 15 Sep 2023 14:39:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5C2556B03D5 for ; Fri, 15 Sep 2023 14:39:53 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2A0ABC07E4 for ; Fri, 15 Sep 2023 18:39:53 +0000 (UTC) X-FDA: 81239695866.25.9B4F52F Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf09.hostedemail.com (Postfix) with ESMTP id 6FB6F140014 for ; Fri, 15 Sep 2023 18:39:51 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=h0SxLgQv; dmarc=none; spf=pass (imf09.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803191; 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=ZopmvSWX8ME3+zE0xLlLj6n28P2bDkBcY8o03Qh+UqI=; b=cCajq+i7XK8m5ucd9mzMxiWQA7eib6xwrrESNhfW8ZFxaShSH+MBUBgHt/Vb6Z8bsqKcDy buR0oNcHovyDrocmdTxcz0QPk5QxpyUzjNVXFg98JAOBHO6VHBsWCWrF5IJSQe94KE1ay+ IEpi22ZiVoUZAp0ZwDEqfV58Be00AkI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=h0SxLgQv; dmarc=none; spf=pass (imf09.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803191; a=rsa-sha256; cv=none; b=iEvW+YBSBoqNHV5QIbqqHJtudSKLzC3O8e+XNYW080msFamRVRZwNYhnHmgGSHe9KbeK9J RHf/f2uPfb8PhSNOzfEhs8M5im8PPqSCAyxgbq/W8wQuQTu1VMlq8EtqXmDCq9t5R8weTj I/abRSYE1qjRzyadGJXltJGinDIEqcs= Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (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 4RnNK03XV2z9svg; Fri, 15 Sep 2023 20:39:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803188; 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=ZopmvSWX8ME3+zE0xLlLj6n28P2bDkBcY8o03Qh+UqI=; b=h0SxLgQv6vJA6JwNxNVopMuk8gFh3dpnTipX3yD3gI900/92roHKFWISKT5EJI3wjM9Naf H6yZ4HQEjxk5IdQCF6prjkl7lI5pXvtu9GxWSpa+Du9TtKgF+FqptplkTRnG+dhPZwnA8m Btc1TNZQOt5CE/68d1sxPOoODwEE9dFTEUkkoPr37EiTQ50/jRoHUZmNBHz1JHwYkE+OZE BPHSoI9PwJXlfPk9ZynUha6TZTNjWfrH4kJTDhHqX2Ktx+PHv9KPF8iwnD9wdArlP0aZmh jshWljg/ktY+MJi3EV7SfFTaY2P7wzKqkE3C2+QdFUD16Ip7mIXMcOKu/Exo3Q== 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 20/23] mm: round down folio split requirements Date: Fri, 15 Sep 2023 20:38:45 +0200 Message-Id: <20230915183848.1018717-21-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-Server: rspam09 X-Rspamd-Queue-Id: 6FB6F140014 X-Stat-Signature: 8ezxs6kyr7mfp3xuxpdjjmp8ouwpwhgb X-Rspam-User: X-HE-Tag: 1694803191-31503 X-HE-Meta: U2FsdGVkX19X5KbDSAEpJ+dg+lUlqAwOaKnRdBitM9nVogeHmdgeOY3850h7gIEE18oniwEl0xoE+bggbA7Ga836CpItYH8rH6SaM2ot+Z8HR/VJff7UZvzhwPv9hwPahRyR6IMi2E9vwpxKpe1lq0iIg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oLtBfSJVPBTIKFwOojXZd4s9gC91lMRE1P9BfWyMEa2AMx/XqEDAMiOhqEjW9Psc/tQRz7MZQzHXmsmV5xNmiag4+1Xt0/1+wCbjvHx8PZAwVwgabcOjDQhVJJdwmkcjTw== 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 When we truncate we always check if we can split a large folio, we do this by checking the userspace mapped pages match folio_nr_pages() - 1, but if we are using a filesystem or a block device which has a min order it must be respected and we should only split rounding down to the min order page requirements. Signed-off-by: Luis Chamberlain --- mm/huge_memory.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index f899b3500419..e608a805c79f 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2617,16 +2617,24 @@ static void __split_huge_page(struct page *page, struct list_head *list, bool can_split_folio(struct folio *folio, int *pextra_pins) { int extra_pins; + unsigned int min_order = 0; + unsigned int nrpages; /* Additional pins from page cache */ - if (folio_test_anon(folio)) + if (folio_test_anon(folio)) { extra_pins = folio_test_swapcache(folio) ? folio_nr_pages(folio) : 0; - else + } else { extra_pins = folio_nr_pages(folio); + if (folio->mapping) + min_order = mapping_min_folio_order(folio->mapping); + } + + nrpages = 1UL << min_order; + if (pextra_pins) *pextra_pins = extra_pins; - return folio_mapcount(folio) == folio_ref_count(folio) - extra_pins - 1; + return folio_mapcount(folio) == folio_ref_count(folio) - extra_pins - nrpages; } /*