From patchwork Fri Mar 29 07:37:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13610257 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 B73BBC6FD1F for ; Fri, 29 Mar 2024 07:38:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 129BC6B008A; Fri, 29 Mar 2024 03:38:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D82E6B008C; Fri, 29 Mar 2024 03:38:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE0E86B0092; Fri, 29 Mar 2024 03:38:16 -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 D24D46B008A for ; Fri, 29 Mar 2024 03:38:16 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8DD1E14118C for ; Fri, 29 Mar 2024 07:38:16 +0000 (UTC) X-FDA: 81949273392.04.16EDC04 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf12.hostedemail.com (Postfix) with ESMTP id CCD7F40005 for ; Fri, 29 Mar 2024 07:38:13 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EJwD6Xag; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711697893; 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=UH6LjJfXkA91u7B+LxuK1VjYI0jSAUD0s0KZGUYpa9s=; b=ecG/PzoiOGH8e/vn6LSlPl80vurJ/b2uV99XLhmLeqZ8zgPkZkS+F3xsVPGoEamdrYbMYa L676lM/hdLq32h1fjz5p4X41fWfjxjT7UpsVT5a6XCV80zPaNu46h/46iJXYCe3enOSVFl +it0oAck11z5apbGKQnJd0tW0hkZ7EU= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EJwD6Xag; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711697893; a=rsa-sha256; cv=none; b=mAlevEFewvOmIvqUF3LbgFqpYBeAB7fVKz5a5fygo3E+y9MuesmprAqP7ZrPUqiFdfJVaS BYMsKS/EabzkEW3VpajYoZg/oR62sYxE6JWMWFu7Xpyr03mmgGHszSFuhBFOGZItwM3PRK FYy3siodVKfXnf4NRj+/OfO7lLGloOI= Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1e0b889901bso15964505ad.1 for ; Fri, 29 Mar 2024 00:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711697892; x=1712302692; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UH6LjJfXkA91u7B+LxuK1VjYI0jSAUD0s0KZGUYpa9s=; b=EJwD6XagA0IPPkGk732sH8nex4zPKDeqJ5n8UaxvEDZaD4MBtf5t9C6VC8vxoPiBNM +2rpP4l6NeXKHh0gQi1hgUOofEAqTFvPGT6eQrhN1Sh+SlDUpywLdXgeVk4cXxK4jhU1 jjolmESvYhga8d7DjTu3RRtqjpjtOJ/xtevJDgecH43tZUmG29taToNlKqZ0TiXtOnF3 iQtM5M9tWSUYtI13g4iv/DqFv6S3C27fipbatMM8Qel2S4jZL2KxogqMYK+lDQ8R52pr 5LBNfc8Kl/LgiJz/3JiyTS4WRe35jSnXNdgHkXg/XmLwOw4DNgsmNO1XS6yBMQVGbtGu IjWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697892; x=1712302692; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UH6LjJfXkA91u7B+LxuK1VjYI0jSAUD0s0KZGUYpa9s=; b=foDSuIvMFUSEflLiahq0owB05lVaxOCwNLdz9W+HM7GBS69YvWrxJxqIqMl/oiukwU vtXmU2hROoI8NzioI93F2JTIbgixkt1fN87IU5wnpcCGd9MDaMgWb0Uvugr/VJxQg8Ji ah48xFz/WHv18YU0riBY3W4U/MQ+SXqw9XPiGdktfcmIeN9raZipn/XZ+HiOwgTvwrsj 0bTmMG7RotSOebIDBVKN2ydG22Z/1uwo9htImr1mAk3d4zGFDuV3bPkMUD/XaX48tXr6 2ro5TQ6izE6f78bxd9nOyhkExM9GVv2T1lmCsjPepkwvaMDCyvlZkZjabVNkxHnqG4z4 KlsA== X-Forwarded-Encrypted: i=1; AJvYcCVPMit+0WKolzKLPOEnWWRNkydng+qwmpe/r8lis6zk60EUg0/TX0t68oBdJApEKfbdk4bjFIzQkhnRE/Mtpiq+R38= X-Gm-Message-State: AOJu0YwdFrm50vNikru7g/3VFIEeJN6fcBMVwqqQg3QMuB64WwT6k1jL KDmEacireWTM9vQIdXMtxDNhTU6GcD40KUOs59SZns60Qu0GAnsW X-Google-Smtp-Source: AGHT+IEHulJckipKHW1jh4cvk4Vt+Pdv4pdpJpi4h6lIXpXVb/IaR9agZUhqfR979Q95p2x2DSl7ug== X-Received: by 2002:a17:902:f790:b0:1e0:93a:e681 with SMTP id q16-20020a170902f79000b001e0093ae681mr1833427pln.58.1711697892361; Fri, 29 Mar 2024 00:38:12 -0700 (PDT) Received: from localhost.localdomain ([2407:7000:8942:5500:aaa1:59ff:fe57:eb97]) by smtp.gmail.com with ESMTPSA id h6-20020a170902f7c600b001e0b60dfe1bsm2844821plw.197.2024.03.29.00.38.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:38:12 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Barry Song , Ryan Roberts , Kefeng Wang , John Hubbard , David Hildenbrand , Alistair Popple , Anshuman Khandual , Catalin Marinas , David Rientjes , "Huang, Ying" , Hugh Dickins , Itaru Kitayama , "Kirill A . Shutemov" , Luis Chamberlain , Matthew Wilcox , Vlastimil Babka , Yang Shi , Yin Fengwei , Yu Zhao , Zi Yan Subject: [PATCH] mm: alloc_anon_folio: avoid doing vma_thp_gfp_mask in fallback cases Date: Fri, 29 Mar 2024 20:37:50 +1300 Message-Id: <20240329073750.20012-1-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CCD7F40005 X-Stat-Signature: pp34edjmiscpuih4tsbsr4wkp3ex7aab X-HE-Tag: 1711697893-582952 X-HE-Meta: U2FsdGVkX19+kHTJOvPrtj3W1UKNAS+2ZnV1e+0fTbtU2YjDuk48Goy4x+fmrNiWAyiyT5JbUpEPU0JCitiyfDLf4FmnKb16kdoHg8UoOH9QA3LsBfQdTqL7tSx9OVnizYmTmDwnetH9OR9QBz8NRQdb2iTHslb28cNm9yn1GEJ8tsgn2tit26BDbBU/mpII8ltFO+TOxYInL8b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fnbZ6hTZbgfR3cXY7sMW87DRjC+wUONJniD+WJjFbPFDSXt0czYJWLuvPj21M3LuQgiTwc1JlPJjB3fsFrGdGkJLWKtk6NE1maMs4FYh03ByxpMP+3V2Mu7Gaeg1f5GirbxxOkhriIb+WL6vxb50yuZ9RhJf+s6Q8vjb21djyJC8FumfZdVYDiHF1tdkqT0UGTioNVLL2Qye2R368D+v9JhLejOrfLxQrJ/D5ZR0y08d2aqX5f1RithRzxHuG0iBLSMuL4H/PAeQGikcKTOwvVGd/XKz/dNDeZ/miSTBrcZehJlGmIuW8huBP218T+UwzBRWP6vFv0qgYnc0cEZtcOZGv/oOgxYyQai4i9gQ5zjdWOgazGhLnwj99n62z8si0b5ix1SCLYWGIh5Ng55fm3CZcV+wFcuRo6sLbEXRUjRzB52T9tKgWMiwRr8BfaWVX3qH4usF5XjtfaSKHZxXBU3tS8RCxWsjggkyHi9BLF5L6gyJzwiX8Q6ywO6YFUTDCu0Z+f+tWyHeeJTHeiypjuEWFQvTQNnOLyJ8wxm4Wdz94ZsQcCE18EhozqOYoNcwsS9X8cGvZFteC1LOsQ37DYqq3wNu5lIhY9jI8nT4KLPRGO4jwGoB/zSd+n3p8= 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: From: Barry Song Fallback rates surpassing 90% have been observed on phones utilizing 64KiB CONT-PTE mTHP. In these scenarios, when one out of every 16 PTEs fails to allocate large folios, the remaining 15 PTEs fallback. Consequently, invoking vma_thp_gfp_mask seems redundant in such cases. Furthermore, abstaining from its use can also contribute to improved code readability. Cc: Ryan Roberts Cc: Kefeng Wang Cc: John Hubbard Cc: David Hildenbrand Cc: Alistair Popple Cc: Anshuman Khandual Cc: Catalin Marinas Cc: David Rientjes Cc: "Huang, Ying" Cc: Hugh Dickins Cc: Itaru Kitayama Cc: Kirill A. Shutemov Cc: Luis Chamberlain Cc: Matthew Wilcox (Oracle) Cc: Vlastimil Babka Cc: Yang Shi Cc: Yin Fengwei Cc: Yu Zhao Cc: Zi Yan Signed-off-by: Barry Song Acked-by: Yu Zhao Reviewed-by: Ryan Roberts --- mm/memory.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memory.c b/mm/memory.c index c9c1031c2ecb..010e7bb20d2b 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4353,6 +4353,9 @@ static struct folio *alloc_anon_folio(struct vm_fault *vmf) pte_unmap(pte); + if (!orders) + goto fallback; + /* Try allocating the highest of the remaining orders. */ gfp = vma_thp_gfp_mask(vma); while (orders) {