Message ID | 1743715309-318-2-git-send-email-haiyangz@microsoft.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 C5B1DC3601B for <linux-mm@archiver.kernel.org>; Thu, 3 Apr 2025 21:23:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8062280004; Thu, 3 Apr 2025 17:23:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E3050280001; Thu, 3 Apr 2025 17:23:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD231280004; Thu, 3 Apr 2025 17:23:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id ABD84280001 for <linux-mm@kvack.org>; Thu, 3 Apr 2025 17:23:01 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C873B81192 for <linux-mm@kvack.org>; Thu, 3 Apr 2025 21:23:02 +0000 (UTC) X-FDA: 83294007804.10.76A9274 Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazon11021138.outbound.protection.outlook.com [52.101.62.138]) by imf05.hostedemail.com (Postfix) with ESMTP id 3859610000C for <linux-mm@kvack.org>; Thu, 3 Apr 2025 21:23:00 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=microsoft.com header.s=selector2 header.b=T4cFawEI; spf=pass (imf05.hostedemail.com: domain of lkmlhyz@microsoft.com designates 52.101.62.138 as permitted sender) smtp.mailfrom=lkmlhyz@microsoft.com; dmarc=pass (policy=reject) header.from=microsoft.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743715380; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nFPblPYOVdQOlmBDt/4Up7fcC0sBiRNP6F8I3o6HrZg=; b=pUkWdNXX0M31nSnxKjvlMiGwNiCaGntYqgiSnKezBVuvdlXa+05LplBLr1LB6H6IwwFAUf +LHtz1MGWTFJ+A2DKC15AlBDQO+FxA+fVvY7D4MK4OWBzVs0NAsLKMl/DibgV/rCsnXiEK 9xzgpk0kFmiHl1XBEUtcVMBzgALpHCE= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=microsoft.com header.s=selector2 header.b=T4cFawEI; spf=pass (imf05.hostedemail.com: domain of lkmlhyz@microsoft.com designates 52.101.62.138 as permitted sender) smtp.mailfrom=lkmlhyz@microsoft.com; dmarc=pass (policy=reject) header.from=microsoft.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1743715380; a=rsa-sha256; cv=pass; b=fIpk+iwptG01EN4kXz+RohNYaLLO3n4pNOWoD3U9ORM9nHd6CVfw1dTkTHyn0gemTjcxL1 knLhpxkwXObaqKO3bs0q2xmHVVA718802eyA6HFFQvpNo18HjOYD9vaWvK6z2j9PzGJBE1 MMunHrl7N+iQWvm+vsIBguLoEZqnskg= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SykC9SeFKGjYYfqW1oEBqIHHx86i29thNhk5eBUQmLgst1pHbRaaTyoHxeMOVoIUY59kFh7q6A/hTqxOVCJf2Ek7Dq+s2bfnAyxnsmn5L36y6uBo74COKW09KSTcyAOPXCiilSjItsHdC7BnnjlM9NRm0oHolS3xK3ANAj1qf53Fb0BJqQ1oQ7ovIPBtuwpa+CPfzJNf85ZxooZkdgORr8gDlbtCvuGJxNH+b7hLwgz+8jri8iDtsG95lRHMl7c/KK+G+K/w4MB9GuHlqyx716LwJn/0LFwcLkZIhkJiCRXjEHlUxQoQ26DHJ5Su3dmPQl3t2DtsYSIF+wSaaPWMGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nFPblPYOVdQOlmBDt/4Up7fcC0sBiRNP6F8I3o6HrZg=; b=ehZAFDizFJGesGDMjiOtrYrs4yvdHZplSEHVQMKXj9vrbWDArkp67InGlcGd6xhw0cxt+9g3pzkutHJEMNxtT7QVakULNAiSenZAZrEne04CjbQH3/uZPLilVQJvgPE5M+RRUT6htmLPMzYtkf0mqdoTvuRTevm6M9kiGMOfIkBbT9cHaO8ON7RQHVTNxEm0zrFearaPy5z2SsunfOcLd7IZdT7btyQPe4bAH3tsOiYPf9InNibsiAL6czz4NDFsWJWfbblA9UBDFQOrQkLv9uoKeHpcTVSWUweHSHkYmYwaEEOE52TNjCjC1UgduNdJ7WcvAu7bbStapvS3D/UPbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nFPblPYOVdQOlmBDt/4Up7fcC0sBiRNP6F8I3o6HrZg=; b=T4cFawEIFuIQO29vzTrFKdYh8760TXDW2Cqij1PcHiDneM+Cgg3FKPRLEf25A+tM21CoD8SWCH4vb0eg5rwFvuRiiE2JGEXyI0Oy76EhjwpTbL1ABso2Epmg+igfvuYYLqs9w+yoluooDv8Qpsjf6sJmMY0Hj+x/pbmRSp0WrUs= Received: from DM6PR21MB1451.namprd21.prod.outlook.com (2603:10b6:5:25c::16) by DM4PR21MB3154.namprd21.prod.outlook.com (2603:10b6:8:66::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.9; Thu, 3 Apr 2025 21:22:57 +0000 Received: from DM6PR21MB1451.namprd21.prod.outlook.com ([fe80::7a3a:a395:66:b992]) by DM6PR21MB1451.namprd21.prod.outlook.com ([fe80::7a3a:a395:66:b992%4]) with mapi id 15.20.8606.022; Thu, 3 Apr 2025 21:22:57 +0000 From: Haiyang Zhang <haiyangz@microsoft.com> To: linux-hyperv@vger.kernel.org, akpm@linux-foundation.org, corbet@lwn.net, linux-mm@kvack.org, linux-doc@vger.kernel.org Cc: haiyangz@microsoft.com, decui@microsoft.com, kys@microsoft.com, paulros@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, davem@davemloft.net, wei.liu@kernel.org, longli@microsoft.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm: page_frag: Check fragsz at the beginning of __page_frag_alloc_align() Date: Thu, 3 Apr 2025 14:21:48 -0700 Message-Id: <1743715309-318-2-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1743715309-318-1-git-send-email-haiyangz@microsoft.com> References: <1743715309-318-1-git-send-email-haiyangz@microsoft.com> Content-Type: text/plain X-ClientProxiedBy: MW4PR03CA0048.namprd03.prod.outlook.com (2603:10b6:303:8e::23) To DM6PR21MB1451.namprd21.prod.outlook.com (2603:10b6:5:25c::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR21MB1451:EE_|DM4PR21MB3154:EE_ X-MS-Office365-Filtering-Correlation-Id: ac0ea461-3c88-450c-4555-08dd72f5b42c X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: OrlDZaeFgjh/eJb93eNfmei+SehZHcFIB6ut4ovpZVLdZDRtRG458bPW1etxMGVrz9Ue+rmrKxs/W1ae/j3865KjCSkhb5CpIXwW28KpFgWkgjF41163e6dZJV1R+Wp6jYGMBVF9xkrFoWmj147xBoEGLKG6fU+jIUnc0l3w2Jvw5YpMAh+Eue7J2VaR/qvDlK5o3CilnNc09fe+XtfVhG91cAkNxea2hqrO9trCbAUwKi89Br5Mnia4OnwYNdwjYW4Z1sglQe+6nYjMhRpMx1sZwelUzTmZvycb8tNALtEM0SljYMrC2MkIEfr8FAHA6pD0BXisugNrJ3II/aTczhFOkT7roInbyZ3k4kjjJqOw6c/Ov6C9FDriJW75iHMIK8yRucZerC/9uFTqc2O6K8lO7ZWSCF/EbmIpUwbi0Z1fWWwfgfrZ7/zwT40HXoKKZUEteejXvS53TbD3YlXLuj3TRC5O8qDhx88TfbSdCCxP20+ZBBBmHH+AD9DjyG3CEF/dl9ooOGVTysKq+R+SXo4ZQsVoQDppr9kB0SfufIQvAc3hEqX0+Xd82GAPheccw5rgYOdLkHHqkPwJk94KHYOuFeM8LIVK4y/Gt+7ar8wwChwbdeXaLM10AMcmHf5ERgH1dKSCS5d0QByuzPQfA3c6AWa1DfA7yBhluZVeBD8DQZU3Kkpz7MZnWggtjsDmh5N11tt4XaYjepKdvGcG3PQhILPzyQpG2B5VB6ppuznkiHn7bjEyJjx4PtQsUhUSt+j4QAL2LMtXOAWJyUutseFW+qrSeYdMqd2MgnDGg9rYNTKvseyYn80ST8BfrlhQCorT855zE+V2VBA6XCW2qYhPn/7mE9/lehwOuAaqcNuo0amvCFhnTTRjecbYHd/5eTq24ytYldmRm/klAuI/YeXzsV1aIjEqKk0GvChQwMhQ9HY0IWQF8uG1xi/q9SgGIXT8Cc0OWzM9tFrn0b+UJ/7p7wljU3pjUbaXdCVPpyz+vaoP42XECKR7WU7IGffe5ecPKWbgfNbrgLXZ/nVuWx3jV358p/Fa/sa/05O35cqyeen9inBNimKjZWpvkKL8anxefb/FFuFvcAyPCiqVgJrBByw7dzqZR/90hC19+Y9Ck0Aj7lPS6tn/feuzEUYZT+7Xv3vBGHX4rCjoaq91P3UZMUsibnQ+4DnMkNxPeOOb8HU2Lr6VVZFT739zMQgkmC1W/zuDwcgBOdzHdJDD89Cgr90pPrFDhuXhZ0FvEcLHOj5d98GqPEWhNJbyfsyrzenHPVSBpooBx5oVyOmqx/Xb4DP6odiXNFOcvptZ3KDbthyux9VgZ1fDRCQgHRr61E7LdB25s8/UDtY0hbQVGlk75LaYlVPiaF6hBxp8GheknifAxAk6jPXEo8axP1XdsIR3OoqVUME50T3vA0JcMfPOubpcfYyStnCpReWu+WpOa5EX3pWYX/HWmBHnn3JWoooImgel97QURZjuWoj4/w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR21MB1451.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cjUvpgXHGYh8wP4M/QMQ/DeJymNWkF4hRFgDlMpZe/pN9q9stjT1OivnoqDEILIoCBcThqjtdcCM/iGe70pkv9bS2bFazEPTBB6wNhIneiLpWG7di21jAq9t9njRHcG6dJCSNecBHCKIkzHzzxWoXxu++aLDQXesBd0k8Uyn0nJRvkLIOR+UXJldORk9gu3+vrFlY93BZjOhAzfPBRP6apvJLcc+07mH6FKX/Fj8d27HkpcXVEbLY48zSAHGGgRUZ/lJL8hJ5+R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Uqh7AnIheKMacFOQ1ArCQrqSM3WwZ2QRfu7j/HW+FBE+dAU0Xdz1gHtYw7jlF8+2bgCwL93fPTcWWU4uO73V08P81jrScdzDay2LgJiPWLgbSouyKAYEdOh1EVoqeXW80pc7elfahWxbde8NmaqVOdTo8q/RcN+ngorvZU20FqnAXG3IgocACt80Gt93RdnTOVOhhXTTLD/lGkBPgy1q0RgvH9amv14vJH+zuRlJOTFDVK7BjNjWfu9On7r+ X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac0ea461-3c88-450c-4555-08dd72f5b42c X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1451.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2025 21:22:57.4902 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7yMvcM+u0JUubLeveGFRVw47ua6LsEix84GZhPUKDdGr+B+FaGb4P0CNIniOqZXCxeK5nRAkyS4wZBIIM+0TIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR21MB3154 X-Rspamd-Queue-Id: 3859610000C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: pzuesjnf9jkxmkxsy5qo6tayeu3bymgj X-HE-Tag: 1743715380-340098 X-HE-Meta: U2FsdGVkX18VLwLzBeVy6DcX6/siuR45SOOTkRBzZJ0u0t5tPgIvGAtellVnQYwia2n8F0IPDmTSSxcE9/Ya3dH8z5lI6CAI9Mx2b7PndJ4v48bnLBRSfomSs4Re8MVyvzZD6mOHhh7M3kiadCs5EzRcv3vE5LsPlAd8VZWtqfM/b2hv7NflboolHK1jDLrbnN3mMom2le3drAEZCj3Uowq2tBlC6ySWiYacD5sHLMPWGgD1n1tokqW4ksKG/mgBQz/Amxog1xrTq3LbQUCju59h2iSfDLa/RJoJDHTvAWkqFc78KHP5XAHKfu1HLTaY7pmWsRCJGKSMmAU9VZuIarnkgU02K8U5bcZ/vjwigXjWwlZeWegC1xSa8ccpwLqC900UIKdQ3bS/2+7lEixYH3FpZYPE9K8F3Y2xnMqqu1uOmf46+Gf71ynBmPDUy9rcer/81V194ZEvNcN2kxyMQ1fjW3Pt1e2Smc+bnrls+GoFthUgIrTzCiHNuEufMQ6X8BZ0nTim0vpGHyJFoLC3jQh9RtjXm+clFVSRIg2X2SVusfPFg+/uAPpLr7eYBCge6+jYp/aanAwUleaUEF8zO/ee1xXXVhrn+2uLhkW2gjLut47SWy5R6OyJIbZ8K7VjTlmL76L1Dp9bv/t4lP78RbBn6UmlqmQeUUl9UOZCV9qlx66XPWvSEBC1HHCExlC6stO7HWiNbwdlGSbnI6YsOAHh23R2UG9e3nuAjqiOk38eDm6eLHLpUNCOyhUd/mcMyCbTCDVXSBR8aqSzyk7w0tDqS8rGE+RQWriSuwZz58oU+I2EQjT+5qiJas8CLm2+NvMIOEx8tYD7pYDPv4Au/pizzS+Sc8l9SDW3BqT5VWYjf8iGxpWJ2QnCYsfekbjNyXdkjOxVJRrAWn9irrOQLGklndlN56U+I2Sgc5DfOIyetCUiLldi+axtJIlXowuvrEzvc1xmDUocnp3/yRr pemMql30 m2n+F/p5jNtWELPLl/HfQe72wz22yBA4cSIf6PSIaaaV9a+VBzkXB/Bg9o6GjKZToTyHzwqc6QToeRn+LyLjbEHfD2lIJ2m4eO993biT4yWhbFJAspEg+OqsFB8Xw9I9/2ZpMOG31oBbf3KI= 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
mm: Explicitly check & doc fragsz limit
|
expand
|
diff --git a/mm/page_frag_cache.c b/mm/page_frag_cache.c index d2423f30577e..d6bf022087e7 100644 --- a/mm/page_frag_cache.c +++ b/mm/page_frag_cache.c @@ -98,6 +98,15 @@ void *__page_frag_alloc_align(struct page_frag_cache *nc, unsigned int size, offset; struct page *page; + if (unlikely(fragsz > PAGE_SIZE)) { + /* + * The caller is trying to allocate a fragment + * with fragsz > PAGE_SIZE which is not supported + * by design. So we simply return NULL here. + */ + return NULL; + } + if (unlikely(!encoded_page)) { refill: page = __page_frag_cache_refill(nc, gfp_mask); @@ -119,19 +128,6 @@ void *__page_frag_alloc_align(struct page_frag_cache *nc, size = PAGE_SIZE << encoded_page_decode_order(encoded_page); offset = __ALIGN_KERNEL_MASK(nc->offset, ~align_mask); if (unlikely(offset + fragsz > size)) { - if (unlikely(fragsz > PAGE_SIZE)) { - /* - * The caller is trying to allocate a fragment - * with fragsz > PAGE_SIZE but the cache isn't big - * enough to satisfy the request, this may - * happen in low memory conditions. - * We don't release the cache page because - * it could make memory pressure worse - * so we simply return NULL here. - */ - return NULL; - } - page = encoded_page_decode_page(encoded_page); if (!page_ref_sub_and_test(page, nc->pagecnt_bias))
Frag allocator is not designed for fragsz > PAGE_SIZE. So, check and return the error at the beginning of __page_frag_alloc_align(), instead of succeed for a few times, then fail due to not refilling the cache. Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> --- mm/page_frag_cache.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)