From patchwork Mon Mar 25 17:14:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13602532 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 D76A3CD11DD for ; Mon, 25 Mar 2024 17:14:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 725DF6B0087; Mon, 25 Mar 2024 13:14:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 63ABB6B0093; Mon, 25 Mar 2024 13:14:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DB1D6B0095; Mon, 25 Mar 2024 13:14:17 -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 40DC76B0087 for ; Mon, 25 Mar 2024 13:14:17 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0B85D80778 for ; Mon, 25 Mar 2024 17:14:17 +0000 (UTC) X-FDA: 81936209754.24.25B5179 Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) by imf14.hostedemail.com (Postfix) with ESMTP id 30E8F10001D for ; Mon, 25 Mar 2024 17:14:14 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Vyt71LZz; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.166.175 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711386855; 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=rSbkdxxh6gTQxH+/m3hblAGdhy4V4YDv1roCho2fnaw=; b=GgiF0r8tNODsBmhOTEOO/S58LE0jtXaIiLuIxgBC3AmYpi1uQStMRscVeLoHGv0LdttydD eVxruFOlO2VFx63heqkHP+BKzQPszQo8E9ydAjeZDK7De9VpDlTQN3u1kmTUWGof3jiLGk WGjM/ew7Mxk7/1DM8UKza8xwh+It0BE= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Vyt71LZz; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.166.175 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711386855; a=rsa-sha256; cv=none; b=2eXcz5G2LaTckFGes+YnefhouniLYNL2ohofzXZNW8hhSzRs+CMG0CrJGnjnBXyK6SFkiV 5r15TKtN8vBZoPTtIvRMrIkYNbU6xZiagEYgs1P9a8whuwnrqboppPr1HP8bUfE8XIINuR Jyo3BSIEycYYUcwlwWGgsuzm6u5XerY= Received: by mail-il1-f175.google.com with SMTP id e9e14a558f8ab-366ac8bdd2cso21512105ab.3 for ; Mon, 25 Mar 2024 10:14:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711386853; x=1711991653; 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=rSbkdxxh6gTQxH+/m3hblAGdhy4V4YDv1roCho2fnaw=; b=Vyt71LZz2CLVMaDWB+SX9PuVeRdFp3btY6mCwv7Apzvr8vJEZkKDSqqtL9ZjXmd9/b 0Qv+NhFh3pOMDY9NqhsgUqTmkyA3VElRxtZ6k8h50ej4HB0rBlk5Uu/Kl9Azo76H1S0N lUPDtE+eP2YuF/ECIQQKLImbFFaswJHZs207KFc724CHF+ABwTB7FJ4ivzgEnhNn0Bvt PzshCZqnoEUoNXMRWpxIwUhHVp1B1SpR4mEZWggOh7/m1CD8uGwOBcu8vTAg6hej9n3e X1m5ObBIwyedSnHRcc54a9aGyqDZAKfmgYZ0f4RjILG3AnUyKv4HD9GeW6s2FWnnU9fb vJFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711386853; x=1711991653; 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=rSbkdxxh6gTQxH+/m3hblAGdhy4V4YDv1roCho2fnaw=; b=K4We0SSZilLdYcEyvXAsNabEuRZY/XK2DoSzVD3YQLy9GrY6KDmWWnNVLTZcJz2CI9 VONYynLxjZHdK1W5RSmrQmSJnfKUqlDjWMWlXSf7dG+NCWgRxFNDlJMrcYQul9+I6VTI dXaIsEMWg+rX0JNzLRxK9NBFdUjB5X0keyfSi+Nm5QCMkXDYXwu5JeJtAEE70IRZ4yOu Aye19XHaI44dnKCmW+K5nc+mQXy1WQBGIW+g8eDV8bBkLAwENuuGVKwOU16m2TPTLPZg D/MCv2jLVidRIM3L+DiUP4nRylbjMUrkIoo8nQIuW60P4UH+JrNYkdBJk8D+DGhFaG8b bIpQ== X-Gm-Message-State: AOJu0YwN5kEGqU5FdqdHBuvupabr+bmIBA1Ze14kX6OBUemxm5zbU4Ej 5iOiXQGNvgdX774w6wGL6tDbCtpLUpmAztK4nF/J3fMXqBaI9mv0dqDiMTN50UpZcF5v X-Google-Smtp-Source: AGHT+IHSMojcSRK5YMTPHTkFJtuXwtvofR+6Do+4UqVrwzKlW3e5+hTuNcI2HZhXYkvzvs6sSeSj4Q== X-Received: by 2002:a92:c983:0:b0:368:9ba9:fcb5 with SMTP id y3-20020a92c983000000b003689ba9fcb5mr604940iln.4.1711386853393; Mon, 25 Mar 2024 10:14:13 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([115.171.40.106]) by smtp.gmail.com with ESMTPSA id r16-20020a63d910000000b005dc5129ba9dsm6001812pgg.72.2024.03.25.10.14.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 25 Mar 2024 10:14:12 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Matthew Wilcox , Andrew Morton , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v2 1/4] mm/filemap: return early if failed to allocate memory for split Date: Tue, 26 Mar 2024 01:14:02 +0800 Message-ID: <20240325171405.99971-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240325171405.99971-1-ryncsn@gmail.com> References: <20240325171405.99971-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: sykrhxmbcbscm4uyu3y9p8yda48f8t71 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 30E8F10001D X-HE-Tag: 1711386854-828976 X-HE-Meta: U2FsdGVkX19o+AnSyxkA5fVJKVEUNzfvMbdKXLAtuLpQ7vFNLKE2XiEO5uvqxvxauQL5h1Llx1mX/Zmj/WKhiOH09wBUWoSzRrcAJIlnKJ4MpVyV6kzXmGrUsNXjfcNiqt5hQLZbBj32NfIcPV58Kz6725L9aEEle7yy4ICXEkOhGEJCB8cFcZIb0+wvsdKyoRQ+cGyNtA0PO/EuQd20Winq7d7ILXyJCza49sNp6V0ee7PVahKwAuxcx+09RSHCJk3W5OmKqWTK4yy8if6XOSZcpgzB/CqmhLmmsRBeMOmPpSTUBreegmxYua3jkjH0vCQLkEBRzP+iVFI/e2n2+yjm/pSAErrbM9ibNBrLxuHeeG8UQoPj6y0lsJA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oPZORpOZs5atC8iveZnyG1t2T6ZYBF3umNHKPBZTC0qJExV0tedogr3Tgh0eteriuap+Jfl8MYrCi9FH0K/2kYCmoMzlWLHjuMWO5kf+thu412XM3cLrha5JopZmXJu+h1VpAzdYCQIXo1nogulUiD8zR5i6EzFbZGfE9K+rE2GB0br1WBVhE7w9IdCjfWS67hWdUv1OA4wxcQa6rKVC4tlXDw== 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 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;