From patchwork Tue Apr 16 07:17:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13631448 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 1725BC05023 for ; Tue, 16 Apr 2024 07:17:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A0D4A6B008C; Tue, 16 Apr 2024 03:17:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BE3F6B0092; Tue, 16 Apr 2024 03:17:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 837706B0093; Tue, 16 Apr 2024 03:17:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5B4776B008C for ; Tue, 16 Apr 2024 03:17:52 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E1B361C0CF4 for ; Tue, 16 Apr 2024 07:17:51 +0000 (UTC) X-FDA: 82014540342.07.00BEEE9 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf02.hostedemail.com (Postfix) with ESMTP id 4774480010 for ; Tue, 16 Apr 2024 07:17:50 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=cX0yp+jQ; spf=pass (imf02.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.174 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=1713251870; 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=0LQlo9tV6jA7edPLPREtk8jPXGN28KNPzfvTbxW9Ygw=; b=zRhyUq8sl02fEcVfJpul+AMikHAwQDNmCAyvDzuVPIDKehSPjtcDjl0A8z9T8SZgt7GUh0 NYSz6WEmcuI5LTo3l7vTkoY5Ttus8eP6TajgWX7EVOSRdH6VAyZfiXnFv/FGsZ1vjrS/qo Mvhhm6C7bUFN6M6WMT4/wEqNnwZXZRY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713251870; a=rsa-sha256; cv=none; b=T34aZeUYZVrdObHR7QuOn1PcHezXYxNt3PtEP/LKHjMLdNNgpSNF6TmLuHtzHoWawi9NLV IV67bHivl2ghtS1xlfxrrlmKmlhKRNaClqznlwLYH9lRpjGF3djfwv6diIn40BgdfbO4KJ lZBRRw4/3pzp5iRegty9dnG/anJGjhg= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=cX0yp+jQ; spf=pass (imf02.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6edc61d0ff6so3747727b3a.2 for ; Tue, 16 Apr 2024 00:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713251868; x=1713856668; 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=0LQlo9tV6jA7edPLPREtk8jPXGN28KNPzfvTbxW9Ygw=; b=cX0yp+jQYvu2pB0hj3xSECgBzZ5ot9E4yVA8YHY61/kZiD07nT+9wrs1sPaG10IeY5 WR3N97LJ5oVLHOmH0tPWiX0jjL9i9/xeLgJu8bNqv3peEgk/HdJzofaR8un9c0X1x7pl ACIew8zpPjJJCQnuJt6+Q8jShCHxJZKiUpM86pHMIAJ+fs3cox0gp/6wSkUkfFcvBK6b 6SxskMZo30ST5ERkg5sW27X0mDyPngIO1sfb04wW3O3WWELUJBaZEr4qZ8PVoHLgzTbj jdIwTmOhQKzsJuFrEJXl3PQhNKl4ofZPF1GHRtLoJSAx7DTVl+tDb1EfmdYHY1yvcISj wIag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713251868; x=1713856668; 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=0LQlo9tV6jA7edPLPREtk8jPXGN28KNPzfvTbxW9Ygw=; b=qfe5aXVlNykpbqH7557GVq7+85QO5YEmUZW9eyzioI2Bh+Mjnrr5lOg4O7rWNqGYrW kloGwaA8nOyQHtKjoSRmMmCqiiCl74I+AemOkG7uUKp5v52UA7YAjOJbr1ht/3+t2kE8 JTYEOr7P4pFS5zxFObvaGWvXj5DGtq3P4wC0midsWyejt0GU0HjX/ObVPi7RrZVO4pOQ o3S+QTgLuEzGqidaSG7OnQUaECPj3Aa2C1khntt//UC+BFg+WccNBcLSDfLd+rE6v9vT 5jXpP83+bqgG/ZI0f30l0JGeZkBXYwfqlj/zs53H/+2FZrJxI15sZ910qv/w94C6M86J UE3g== X-Gm-Message-State: AOJu0Yx24kY1kghZICgcFirh70WbC/7kwKEjbWTXC7/4cgKirmoKuTJy qgPhaTTkC23+gz8UJqPWtG5jnQwG5Kf1W0jTnDUowOLm5xFgX6qjk6MAdQ13 X-Google-Smtp-Source: AGHT+IFA2zmy9+KvgrKxSYzQek06HbyAOJH+OqT9zi1O7kh6mqKJgpjWl+AmhEUdNRhj7ZdCRoeZAQ== X-Received: by 2002:a05:6a00:399d:b0:6ea:c2c7:5d6a with SMTP id fi29-20020a056a00399d00b006eac2c75d6amr15984911pfb.2.1713251868205; Tue, 16 Apr 2024 00:17:48 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([43.132.141.21]) by smtp.gmail.com with ESMTPSA id lr48-20020a056a0073b000b006e724ccdc3esm8340029pfb.55.2024.04.16.00.17.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 16 Apr 2024 00:17:47 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v4 1/4] mm/filemap: return early if failed to allocate memory for split Date: Tue, 16 Apr 2024 15:17:19 +0800 Message-ID: <20240416071722.45997-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071722.45997-1-ryncsn@gmail.com> References: <20240416071722.45997-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspamd-Queue-Id: 4774480010 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: iyjx1rc7cezrg5fqonh9mzeoyqdynikd X-HE-Tag: 1713251870-962001 X-HE-Meta: U2FsdGVkX1+E7WkkC4BE4us5I3/mbYFfLWa1pgWf2T8sIpGJuTUJlP8fdWwuGKEqW0y4W4myegvu00oGGbBH1+feDHu0JEyoi7qqIHMY2vs05WTSuTBf+y6G738A0O84fmIcXkY94r+B6uHvZGelKDc4JTZBEJneuUx8T6bYyBh6Lg9gpqHfx/0zDv+KcKx5eEDYZl490btnovGY5t+UG5kB476+zYY1Mqxvf6F35DN36VF08MfRJ9IcSbZTVVKqVBsJS9BWAoUmv9uH6j5Zbx+owj/yO8UOnQHIK76C/ZWhHS+B9ppqvGDaTufeKyq0IdzEIKHRHuxpVSfIwnMZdICGrYFPZPkWu7tEdpEgjrZbHqN9azFdcPy2AxwJtMMaNhnQiS/zfddUgLCqpYBh0f4lMA/28CZZJrbqAf2Gp/sTrOunVLcUyAS6LVinrfwCwnZol+lHQX0r50xpoRtVd+SBJH9YhSX0sR9wLI7xNhrJlpgwM618dX2NK6T5Pr3hPAFzd7b8OHlFhwMgt2FZ27BNBMsoCa9XvtIIXd1z/8f3xh8uf/Ubs1OpsaqF8QnwW0Jdl38rD4m1vggcj1x3T1l0AwD6WPbCHAltySwe7e6xLkzGYFPuqzrLaStbMIO+a5I8lInoidsHLZWZ2GB7eWmWRRG9vhIAaWAfrYITnAkZ8KP3C1sEmD0AJLWPUdF4Cc39Sl/FaDAnkz6rb7up4hra+lWPNyLv0B/q3CS38gWroIPT7qDmJiPFMkGYEQTudS1nXXC57/YsX41RcUPg3umaM/glYvVf+FGwLy0TRFvwxldS0oi5NcPgTDW7dgwcgmk1tT8UKdNjeiszw4lK3zripNSBgrWHMZpNwOMcJsrHNC4D9LOtBUZQHVjn93U2i29rLGKzn6RJSi32QrgXSvgw++LKCNVDDiKrx4Cjdz3qzks6ZYT2AsgLZ7BKtCjDL/reSL/D+lAGoDNgDIP 5vBE5UAv U4hZKlvkJt3Mk9KtmuE6R7vv1CazBCHvoqfQG0PSY/twVMgKLcgCxxLlcmovXXNv2ek4FrS5YspJE50i2ZBclLwIeHgg0OIsFJz4ekXbC8pmY4QAos4vfVQJV55d7KrKnS66EB4Z8sk8n83un9Q7n5alIYZI8BvOXdWnpO5M8urMs1hcOU/pFcQl6JTXs5qixQXm/BBkK8soDb5vmTsN2T9UdvZGEjeQKCa26LqVoi1ZcaQiCSZTYtys1cZIFatrruuov 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 30de18c4fd28..d447b36ffd41 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;