From patchwork Tue Mar 19 09:27:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13596499 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 ABD4DC54E60 for ; Tue, 19 Mar 2024 09:41:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0891A6B0087; Tue, 19 Mar 2024 05:41:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 011C56B0088; Tue, 19 Mar 2024 05:41:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DCD626B0089; Tue, 19 Mar 2024 05:41:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C7EF16B0087 for ; Tue, 19 Mar 2024 05:41:45 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8EE8D1C11A8 for ; Tue, 19 Mar 2024 09:41:45 +0000 (UTC) X-FDA: 81913296570.16.9717EB9 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) by imf27.hostedemail.com (Postfix) with ESMTP id C208E40009 for ; Tue, 19 Mar 2024 09:41:43 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ABo4DgVm; spf=pass (imf27.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.167.176 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=1710841303; 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=ZwvTELM6ByipvSR/wfDTLW1X7/KlLM1aOXjOWDL7DtM=; b=y8d10pFZIt5bZk2vbruc7g/JO/3qK9HyLAmZgM/G/gLYAuSlQJuqrdE+j6EK81azcB92uU 3KkYDfytJhBIrf/Gi6CBKSqeK8BsuhkjlK7tex882AX1XSjcg2smM3ItAHcspmHNv1yFxO Do9F9QdIJhYV3wzVcIIV7AzVHmaZzGQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710841303; a=rsa-sha256; cv=none; b=KgOsaZLJHUvK3lIJ2jHPJHecNYR84YYkb+EUq9GVdNVh/e4DmhIz5qUkaUJtQzBYBKeV6n lPRHLjdAOd4GKhJ4rpWf+iFbtX9TvpfNQBjj+jJGbvgh/KlvlL+VqXqlla38h2bTVvRlYS LSpaLzoM160q0s9gkNmTI0s2faqqQXA= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ABo4DgVm; spf=pass (imf27.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.167.176 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3c39bc142edso85988b6e.0 for ; Tue, 19 Mar 2024 02:41:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710841302; x=1711446102; 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=ZwvTELM6ByipvSR/wfDTLW1X7/KlLM1aOXjOWDL7DtM=; b=ABo4DgVmZkl0TlYTbYvkCf/F3kApWxplqoYQl07MhSOl1iIHEqgPLo0RJVUAHTarvu RN0UhYsM2TTf2lL0cMBDSKLN+9UnIqWT8/xk2SLCYZBO+9rLPlCV5ouiGNGwtT2HvlKg sFixxgeRiSso8WkJNbY1Z2yhrwxJF5maWc4lihLhJgGiYatIlc5BDDI6cIEw7/vpsIaX uzSQLEIqmrwD5yM/kiVWCyMSxFtSFkf/aNJji4mI6ODsRI5zIAAa01hpHnJia6oDZPHm A0OUEfNv4bzCAsaZY5ag2QIaurzaFBl+qof4+Pt+7eAg5Q62R0UZNj5/vBOPc9v1TF1z MWnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710841302; x=1711446102; 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=ZwvTELM6ByipvSR/wfDTLW1X7/KlLM1aOXjOWDL7DtM=; b=Enii0lLdZBdPYqJUOm1Pp1JK6+GyeW7i4v2EMFJ15qag3G64c4Wd0UzcSt1c7eWlhH QZl0koibcuUJhx90MqH67wwVBzauek5jcDfVTOqQPj4km0I95TqhKvNgRarxMuuo7VKf quxN7IhHWd+/8a5qFOU6xxMSXCltQ4F2aMuUQmdQ/XGFnfS1YmSEVkVSYCou8u0dFMFU 7nO62KTZshV8Vg9RGLt7HVDznsnIbhP/o1X6xQ3XAyvV64HbY3Fhd4XZkiQQ9tc27IlJ uyabLds7gQxknLzE7eFhKQNf77uYnWuui7bmPF5Tk0NU7w8eWVr4GTXyMCSPnRuCVxF0 bcZg== X-Gm-Message-State: AOJu0YxYDTUzUQ9FwLx0mTLxl6aGOyMRpm9tklHo34rfIXp8qPUtfhvL m6Q/cJJ7r0aal52PSjRwnBZtv0BT+xmC0S+3dNxsxy5Ju0IuftcjvGryafVa32osvLyu X-Google-Smtp-Source: AGHT+IGwOyvn+IjcJV9WoC0uqc9TVdMrZljGfip5NbPFBLB5b5fIZHNI4sP+MYpz3oKDJCbVHW9TSQ== X-Received: by 2002:a05:6808:1524:b0:3c3:88f3:96f2 with SMTP id u36-20020a056808152400b003c388f396f2mr6552697oiw.0.1710841302069; Tue, 19 Mar 2024 02:41:42 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([43.132.141.21]) by smtp.gmail.com with ESMTPSA id i185-20020a62c1c2000000b006e583a649b4sm9708761pfg.210.2024.03.19.02.41.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 19 Mar 2024 02:41:41 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH 1/4] mm/filemap: return early if failed to allocate memory for split Date: Tue, 19 Mar 2024 17:27:30 +0800 Message-ID: <20240319092733.4501-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240319092733.4501-1-ryncsn@gmail.com> References: <20240319092733.4501-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Stat-Signature: 1aaay8oqmjyptqzc6t6susem1g5wfc14 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C208E40009 X-Rspam-User: X-HE-Tag: 1710841303-718610 X-HE-Meta: U2FsdGVkX18au76dAG3Oy1/hDCLYKbRcdQQSC2BflvDtGgoTgnVRbidkBfbI4dtPCOjklbEciocXa1MJc8sLnlCY9VEDpRQRdTZGanO+xlUaraMuadKqzXdLkpYEv+BBfr9AdmNKQfT4Llqd/gwfOXLvjrFbbF5sKaF2hmGPP52ma5KqJYuhN7Ecn3EvKdvor/soLAT2T7EAbRFVHkHfvxKeGdfGwcsC+9pWoVZr9ehY7Rz3YT2kptHLQEhe5m4MvTcg4/W0qT8Int3cxSC9vBhH9ekt+j1PrJTcWtCu1QM7XLagfCNIyS3YkOxI0HAVrT6MlUHOkocHI9UFx/7CQbsGaxONaSZO5DUVRsm/OLj5YA4/QxprEFuslTv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ZSyJRV5exS85+zeftHsb12X8Xg0WTPrZJmJwZbPEQ4h5djUDdeoLmkqaDZe6LEGuLrZDWAyQi2jLVN/zTvz01BUWhR3EV9y2CzvtoxSFpLVdfZamfPZ6vcF5sonfEYT6OZGG0xFMshMPcTha8iZHIR96m6AI/lBdw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.004087, 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 7437b2bd75c1..f07ea0b97698 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;