From patchwork Mon Apr 15 17:18:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13630432 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 56C01C04FF9 for ; Mon, 15 Apr 2024 17:19:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D570F6B009D; Mon, 15 Apr 2024 13:19:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D07486B009F; Mon, 15 Apr 2024 13:19:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCEE06B00A1; Mon, 15 Apr 2024 13:19:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A1A666B009D for ; Mon, 15 Apr 2024 13:19:17 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6D49DA05B9 for ; Mon, 15 Apr 2024 17:19:17 +0000 (UTC) X-FDA: 82012427154.11.793FDD7 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by imf21.hostedemail.com (Postfix) with ESMTP id C67EA1C0018 for ; Mon, 15 Apr 2024 17:19:15 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=juV33nph; spf=pass (imf21.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.182 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713201555; h=from:from:sender:reply-to: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=B+L8KNGbsq36FmjcGvQ6kYVRELiG3WmiEI53/0190Sw=; b=Xjn7jQvnMM2PajgOCVVaVdnnEl7MlMnSjfGJpcgMeoRfbQuFXsZ8dfdHgJ9nmMowQir0WI Xbl/7IoW1G979p6yowxzg3eJ+3G9iuyP1uztVAXamQfTT1XUqVGgIJXAp7dlt74vjNKkdg Z/8kpiPbnjL5njaacJyml7bFlAyDflQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713201555; a=rsa-sha256; cv=none; b=EFV6ilVfNTBMmcly291wpJ4BIupRO0uynrAOPEckCQVuNLhrWCrLBp6s+kJOqG+OzcWvHM SgWeUwmIEpSVFUo7ytKnrMZBBNZMsUUj+tbUemBfXY/ZFC09nnSRVRdiV3Ml7+7hFj6xNP afnVIQ1T+IDMdyYJ0XZTkjsR/GH9Ep4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=juV33nph; spf=pass (imf21.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.182 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-5e152c757a5so1822087a12.2 for ; Mon, 15 Apr 2024 10:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713201554; x=1713806354; darn=kvack.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=B+L8KNGbsq36FmjcGvQ6kYVRELiG3WmiEI53/0190Sw=; b=juV33nphBL9IDeBbhyN/yVF0c/j3+yKPZ+ASegxU4b0YHUhmKJwJuocQRtnYGodle0 ubA4kvVrOuiVorO9WuzLkCqVVpj+NdyKLwKTGQ6PscKg32SWgpsEdh7GpwwWcl/EWWqi wWozadi0ugd3RufvO6PqxaOqfmFlJjd2Yusfxam7M4O224QD5tYKby1DBSl6UbnjnsCU XxojdSWa/AaGSZMobVjXnZnu6NrQjWA6IqRbizVYch0PzsRkPQoSPaJPUhvM0Q+6UlYg N+0bpU3Xli8TwkCS6owbJZjqnLkzpGiNAzRULElC2XnvP6bK+P2qySPzEQQxRX0KLYAD lwWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713201554; x=1713806354; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=B+L8KNGbsq36FmjcGvQ6kYVRELiG3WmiEI53/0190Sw=; b=LLIcaI4SBo4oxlbKYMIrNfEJZXivWxEsWRQqaruk2f8yVwv2cyffFrkoc+WUPzp0ft M5Y7Q9huqBWHzHDpeWvN4i3N0RIwOAOwDnDyjwuTq+vP27zwyybJu6A9meBaMvuCKd1V wgZwnvET6Zpp4qCi/52LwuLNRjl2CfXSdB3oNE65yfSVG89CwGB2Vu+whGuOOnRsAWNU NjqNdIhrbM2qW0loBM06YsJ2L/HfdMqkjqeiQChNsDHcvkq7taucBk9qJAzcFfWID8Pu Iubi2tVurbsbKq76XyqngEwDoaUCWzuTWR4IgfaWRBxglLRVVcXqldMl8QDAc6YSB2cw dU7A== X-Gm-Message-State: AOJu0Yz0RD8TEJAEZNvEgYsuChNT/bUhOGXJ48rpTgSg8vX2cT4+6Jia TDygtocibLQ8ukFhctQX1BywrqvksfKlf+FkBwZYN9g0An0iJ7VkyCzkmhWY X-Google-Smtp-Source: AGHT+IGZsDnsN/0G69F9r9pl4nCedE8as+ni4AOnw741cJ5yApDTX6VIYEFjdIjzcaV4wIkNMeB2jQ== X-Received: by 2002:a17:90a:d998:b0:2a2:b096:f1b2 with SMTP id d24-20020a17090ad99800b002a2b096f1b2mr7627869pjv.32.1713201553844; Mon, 15 Apr 2024 10:19:13 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id o19-20020a17090aac1300b002a537abb536sm8751648pjq.57.2024.04.15.10.19.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 15 Apr 2024 10:19:13 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Matthew Wilcox , Andrew Morton , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v3 1/4] mm/filemap: return early if failed to allocate memory for split Date: Tue, 16 Apr 2024 01:18:53 +0800 Message-ID: <20240415171857.19244-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240415171857.19244-1-ryncsn@gmail.com> References: <20240415171857.19244-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspamd-Queue-Id: C67EA1C0018 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: gcmawsyfy4eo5kgj6qnkiuzhgfuhaiye X-HE-Tag: 1713201555-830924 X-HE-Meta: U2FsdGVkX1+WAbSe6dSDJ2xvGEK3riG37OojQcDDvqeGPSwfYZ4t0SD0OK6AM18RLrZPDjhsnSzm+Fyv0YB/KHftiAPyzcAx8zywZtD9vsaIYNuGXfCt2bbLKVcO6dAf5e4O5w/B5oEDBF5CG1J763l7seMTKlJfqFGEWRBwv70oPdW5ai/1wxQgiZvucppZQP12OEx2V4Fn5hhAqAf+rznc5HSesL5olTlV7BjedjXxuwEaQaCpEfeJ/AiIepmSbEACCi4jx/3xblzV3E3TzFL7GewGdG3U6T2/oe7jUUyZOQJMgOftdWtE0K5eHl3JaUlCEMGe4DpQ3E4Hfb79Av1rQ8hTB6vNd6JY97NND2c72rUU967W1NIwfoHeUxg2KMxBmGan4iBkA0cstX5tijPgzN8YF8KrkNsT3GDce96BVqMKtw4d5tEWUqxJMBcKQpHrY4Cpa6yNeUH79s7Fj5l0/LYJaTOQCggZw66kYM2NpLzfxvWtVGGv9VSKBX4lNeefFflcEeQJCWJdZecpJy72f/HKXt84Er2/Dv1H2lFHep18L+lBMnBdRPnNJI8G57lC9bkS0TJhLaRPwRmb08B22QxinyIQrJ8xNEw/hiUYTnVNWDZMbRTuW/EdNAaFCtU8bq52GqhSI3iy9TZtuV1fdTw62NTU2spHWBFPw/SvrmUjWuJ49xvBsajkxXBaAdOZbQiKWyIyNVZBSwUQncAkruFvWZAK9VVZkaI86Gau8v+LRIFisnkK47SdHRClUI+mQlrkN6YRu2YmjBcJgTveszPnAcB6Iqtv0ZUc/+CEamFFotpJwCSYUA6PL3iTFhscZUOjcxCIETMsnGPiL7EQvwJjEImX5rzkTf5W1djd+jxVOv4UhHBPoo3kcCRQacVrD0JD/t+f4I4TQYHBs0CtHny7T5DxW/l1YUTJtrvM2eUPbAbUCx/45VGvTj4nIcT7FRPTa+uQVoAIpdE XUdOHrRt WeE+iLnsrf41BNRzn13Lv8svgnxEgOvlU/i0UDv6CyL1+XO2oudL6wkph4g72qVk51jsMv7PhQcVLAXsw8Oel+IXP48JEmHKq8sAPC2Ad8BNPEcz5x5c/Jan4pRg3No1ttUik+MXuo6qaS+NBKihLWjx4q1BIHVic3gqD3VVv5qHGRbz/6L7swap2+97gv0DxrWFehEp0WP4ylJsPnz+Z2Oe3r0L/k9nf4PxLFMkffAXi1f/V4j1b6TGtXmV4ItyZIXnprJYQUw4q6WVTWRSzPd9B42593+/mpUI66XJeP0qAWh34rVTkZJ8XVFMWb4tqM3cFLRo6DLpi3tE= 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: Kairui Song xas_split_alloc could fail with NOMEM, and in such case, it should abort early instead of keep going and fail the xas_split below. Signed-off-by: Kairui Song Acked-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/filemap.c b/mm/filemap.c index 480ae6589803..12089c24abfb 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -880,9 +880,12 @@ noinline int __filemap_add_folio(struct address_space *mapping, unsigned int order = xa_get_order(xas.xa, xas.xa_index); void *entry, *old = NULL; - if (order > folio_order(folio)) + if (order > folio_order(folio)) { xas_split_alloc(&xas, xa_load(xas.xa, xas.xa_index), order, gfp); + if (xas_error(&xas)) + goto error; + } xas_lock_irq(&xas); xas_for_each_conflict(&xas, entry) { old = entry;