Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp71769pxh; Thu, 7 Apr 2022 14:19:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEZU8yW/+rhHek82rxo8FpySNd7FI2Nz0jfYNTXkYR5stNrGixzHmoDM4UprNRvfpFcrkA X-Received: by 2002:a17:902:f60c:b0:156:82c9:e44b with SMTP id n12-20020a170902f60c00b0015682c9e44bmr15925360plg.106.1649366368612; Thu, 07 Apr 2022 14:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649366368; cv=none; d=google.com; s=arc-20160816; b=uvJiH8TQc8q6yIwIImHHAlonusHHflyf6bI2dYl7F6Wud3q/Zrxb/kWPsS8MeNToIL 6XFlqc3/G4OpzfWeB8uIXxxGsOptkBTGU7dl6124D8vkpqYXpKvwMdJwylvcYRllxULh xPkkA3Hfwp6IUIaPhommc9S82sNYxQvSd6PPF9+3rFEP5Zt6u9i7QWlPhw4JrJAw3Q9C vXOxBPluNNi3mM72pppSK+XdeSkcxZUULE7iEEeGyr1Iwd1djDtuAzuxY5nNAU8OVZty +F/3YhWUxX3XWUn/kXrrjTLFJihRH6Vt5wbLvk4B2e75MjB7RsZ4weB/3z+m0xXejMgM SdyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=R9d+IdGGvBR16cCmUuz2awSfub2VELhlwQHxcbJCpTU=; b=IVwynESP0uKWsV5f31u0KjWpXqnSHqDsFfXSviVislYiGXoKC2ghd3gnh/0R22lQJW F1EXkKbMbjqZtZjXhLr/4j3loeIW6Nj4DtDszpAIT6jLI1xcAFveluhHZ3aPzypZyNd2 LPhpBwDn99yz6o2XvVEhWJO6fLW93GyLikWV1D4prOmHVw/Q3CsmOyrf2JLGAPP9wWri efBDLLSat9SID9cYk8oiXjsy6LQWzT0jQPCQnHuIMMgw85eyNQw6k57Q/4SofVzPuGwD fIFLszeOBgw2IaSf1IekbViSmJmw2093iucXNWbkdOv6aBL+wR84uWUYH2gLNjNDTsvp 0Nsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (bad format) header.i=@dorminy.me header.s=mail header.b=o8Ioe7+k; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dorminy.me Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s11-20020a170902ea0b00b00153b2d165ecsi790720plg.500.2022.04.07.14.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 14:19:28 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=neutral (bad format) header.i=@dorminy.me header.s=mail header.b=o8Ioe7+k; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dorminy.me Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0E7A32A8686; Thu, 7 Apr 2022 13:11:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239088AbiDGCaB (ORCPT + 99 others); Wed, 6 Apr 2022 22:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231860AbiDGC37 (ORCPT ); Wed, 6 Apr 2022 22:29:59 -0400 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B9741E112B; Wed, 6 Apr 2022 19:28:01 -0700 (PDT) Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 52EAD807ED; Wed, 6 Apr 2022 22:28:00 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1649298480; bh=v3k5Rq11ZVRZywAD+d8FqJVUni9Z9keWfAaH0o9cMLs=; h=From:To:Cc:Subject:Date:From; b=o8Ioe7+kU+1QvlQ8Zf52QutUKXRjj8sWSjX628V/esCXYsIYIuIyZA41XiUjEzv2F jaHN1g+wdcsJQbc+v+adtawCT1frWwN9X5Dj/s8mlCykJaDbfLI/fqnh/XNjwk5O5O juvQj++mThbUgIF77n6H/a9BrD6WaPvzTKeU3t5I6dVp43dU13MUq00zKGyWcS4osq HW0u7P0Px3AXtWhb2fwuwECmz5Qiz624v7YSG6CfcDXlAFPZcUM7hmkBtgfFmIUQQL 1ieHADb4I4/WPAtM0b/ipYVRdqxLv0lEaiCR08kZP0hhfeuCdQwZGfovA1Vp7pmmci yK07jwWbvtSPw== From: Sweet Tea Dorminy To: Chris Mason , Josef Bacik , David Sterba , linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, kernel-team@fb.com Cc: Sweet Tea Dorminy , David Sterba Subject: [PATCH] btrfs: wait between incomplete batch allocations Date: Wed, 6 Apr 2022 14:24:18 -0400 Message-Id: <07d6dbf34243b562287e953c44a70cbb6fca15a1.1649268923.git.sweettea-kernel@dorminy.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When allocating memory in a loop, each iteration should call memalloc_retry_wait() in order to prevent starving memory-freeing processes (and to mark where allcoation loops are). ext4, f2fs, and xfs all use this function at present for their allocation loops; btrfs ought also. The bulk page allocation is the only place in btrfs with an allocation retry loop, so add an appropriate call to it. Suggested-by: David Sterba Signed-off-by: Sweet Tea Dorminy --- fs/btrfs/extent_io.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 9f2ada809dea..4bcc182744e4 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -3159,6 +3160,8 @@ int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array) */ if (allocated == last) return -ENOMEM; + + memalloc_retry_wait(GFP_NOFS); } return 0; } -- 2.35.1