From patchwork Fri May 19 12:39:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 13248283 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 83E65C7EE2E for ; Fri, 19 May 2023 12:40:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1958900006; Fri, 19 May 2023 08:40:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CEB76900007; Fri, 19 May 2023 08:40:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAF4A900006; Fri, 19 May 2023 08:40:12 -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 AD7E7900003 for ; Fri, 19 May 2023 08:40:12 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 76BC41A0A4E for ; Fri, 19 May 2023 12:40:12 +0000 (UTC) X-FDA: 80806962264.25.F200ED6 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by imf07.hostedemail.com (Postfix) with ESMTP id 880EA4000F for ; Fri, 19 May 2023 12:40:09 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=UqY0Q1Qn; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf07.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.208.47 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684500009; h=from:from:sender: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=eLUm7WZINfPJ8EnyZppR+QB8ZeshYnpRD1lp9jOg8YM=; b=tTwJsiIM7ar5KSYYboTKpRjz22VavklEHGVz2Sf82M8qblaseCPbl9/JtmUowvhQ3fHpoy nKpeglsP2ByYvaz9h67OqDlIOEhlFt3LH2BlNzWyeVQOz4KbEFHAN9Wh/KizqhLg2efSsX FBNExD81Oak2nE33P2CthaOUNJOYtWY= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=UqY0Q1Qn; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf07.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.208.47 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684500009; a=rsa-sha256; cv=none; b=6zTYReOrYnPZFd45T226H2ajKcWf3CxnMvytija9e9ufYhWzZbIrF6ryeg1Zz9YByQEsXK eUTa5m/+Ggo+2FvREC4LXv1K1z5M+6X5SxKVYEnHmZkQEPMsqA5b3h01OWA1rvCdfaEELo YlmUAzLy4BSy83VGbDtGBxd4KbfhRig= Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-50bcb229adaso5802870a12.2 for ; Fri, 19 May 2023 05:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20221208.gappssmtp.com; s=20221208; t=1684500008; x=1687092008; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eLUm7WZINfPJ8EnyZppR+QB8ZeshYnpRD1lp9jOg8YM=; b=UqY0Q1QneRWgaChbAJgyXkbGCj5MIeuFO1Mmxqo9b0QVAxAtyzG0jFAVliXTITC41q oC79XjrJW9vlGUQVQJWPUcF9FCRAbWfWtVRthlUqELkW1+wmsNFisu0FKzt8Vuy7O/0r gyMNuX0yd/37Jh6HhJKs7jW2i8YAXmc5zUZTmN3Rlmuo6uaaRSkBGojlNeDxEigi5TXY wkeYQj8gFL6V8RbvUzItTEhn0gtfrZrDjFrQqIDzdEz+gAAc8yjZKn2/LyNCcfsdWYPq V/bJWcjzyGeL1UMuy0CC5C2DgDrohlE58IRXywwbSfuUET9z+ZmQWIUXgcTO6ixIOW9N daFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684500008; x=1687092008; h=content-transfer-encoding:mime-version: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=eLUm7WZINfPJ8EnyZppR+QB8ZeshYnpRD1lp9jOg8YM=; b=RQnz7bv7FYy1/qeNDKM/4dmrzOHukfTrzqUa4tqJsihIzZqQad1GHhdInt/FsDVWDN nFnnZvlQXqO7JubnpvLJhsEwWHstnF8zOjXiAC1XrkVPu5oUrL5dMlW6FfBNKb672UcY ZYkHFWwbg1ajPPpTwH/ZwMus2RKWBRieYOjZo7Sh6rkQymNtT70VS8emWzq4pQ3V4kSr Ueog1I1Z3A536B186HRdYv3mVSwAhsmoIxTR3UQG/srjelx7/9A8ZddhhEoKBYuCgukm bQMymwzVHlDPkTw430s9R8Uf1T0+o2MWmQFxZEvVj2kombtOSTplqIsDEFl8C2jaZhrl rMtA== X-Gm-Message-State: AC+VfDwsWYN6BX4l5kYPBTVvf+5kvfQrzWPlL/+II50ThxA0qdbFpULF a0n3XNsE4g9WBEkh+zc+Mm+tuw== X-Google-Smtp-Source: ACHHUZ7oj3yMtwF1chSvwKUqZhCd0vlmhEuYEkCw7mv9MYs7nSCkZ05x4A7DYg+PKersqbn5+LRfWg== X-Received: by 2002:a17:907:2cc7:b0:965:fb87:4215 with SMTP id hg7-20020a1709072cc700b00965fb874215mr1552073ejc.15.1684500008176; Fri, 19 May 2023 05:40:08 -0700 (PDT) Received: from localhost ([2a02:8070:6389:7d40:e266:3092:9afb:a7b1]) by smtp.gmail.com with ESMTPSA id m23-20020a1709061ed700b0095337c5da35sm2295229ejj.15.2023.05.19.05.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 05:40:08 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Mel Gorman , Vlastimil Babka , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 1/5] mm: compaction: remove compaction result helpers Date: Fri, 19 May 2023 14:39:55 +0200 Message-Id: <20230519123959.77335-2-hannes@cmpxchg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230519123959.77335-1-hannes@cmpxchg.org> References: <20230519123959.77335-1-hannes@cmpxchg.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 880EA4000F X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 54kcje54g4smmqcet6hmasueoiek67d3 X-HE-Tag: 1684500009-773829 X-HE-Meta: U2FsdGVkX19VMg672rtS/jVSEh6MXKmHiMgUNgqxdiNZ3O49SI1i3pqpRBtoVMaoLmThTgn5JIxKPdwvPzRCsm7PudgiAQ9ohkIi3my8/+PZC25vbqi2rnasfzWbyfyc3frupUiYrmVgjGYQ3ba+9COzA6LO+gSer3OPpSMeY532C+bIV+XDxEsZ88dR2p2FbAmH637x2Fpd5YhHwxb1ZqlYksKl5Bg1f+Bcglv/PDPvO3oxt60iWIXf9haqWhjET1sicDMBvQlgLZDyxG5d07cdLmWyHV6EpU4Ypk6eXc8moXajjlFRTB9PsBn68otFUf8t+Yg2bcbj9exaNq7DQ2H/LUSq9HOPDoqoAxajkaPzED+rzKzIjNahpSoK8H3GJvNWDpm5peGX9jTc8ZTc2G0dl2Sg10BSd2zQUN+b/4fn4S14mXANqEriURTInayw35wYgrEYR2LUCgac1oCESjHn3gpK0LMU1hp5FnbzgsvP7MXQ8Ou2iglT/xuC9xYAdCwNgvE1wipfhnZ2EXMiQw8YtaJTjfGS796xC+6nMk4I+WKd/pXgu4vJj6AspjGSpTsEd8nL3S13+xR7S/NeyMcUBbMR9W920J8Gm7Pyx5QsWNyE16Yx4KFWsdY3Oq0vcztY2SrmxlDiN1UDFMhhZ/nQIQwJDqjiz7uLPjufSldJI3IRPNSLMI5QEhX1JJ3PprDdycYZHobtbd+Mp+bPu2wnE3R+uJ77tE7PrJ1IVCVZ/x67h/XUiFmSZmAWiXe6FLZ4lk/bJMKJpdbEgmPrUlsDTT0O6qjZxS0UviODqadCC583A2m/CPXoeuoOkFlOUH0XtyUcsT6lI32rcGtMZk80nAggWQvXN2NaA+Yzj9VXJRrMFPbMfjnInyMxwKLaoxgVfBz7E3MhZBocohAFpUBjImsVbaSbeBGIbNcMFj//U9cB3dGJ1eea9BnGN83TeoIqaFDzPydDKJ4AOTI wRQrKQ0k VChAchb19fHVnrwwVEz2SwFHcghuMbEmn53nbZqNHK8kT9Na/uDB97dzsc4rijcH29JKnC+dBNfPvsws5WpDwP1cOdlFlivoJJOkUtnnGd4RGaX4p/uzkrDDjH/Vn93FrRW3OMTFtWEx8p4NfiS9Qh8fRddwxhEmJDG1vVohfTPxXuVwpRBRPBUQdmma44pZnCoA+iJoYa5itc/nGoDRWawcmy6QPdA81+m3M5ngfxtDJb9Gn19XQmFE/GYGR+aSR5gV7gpQ148uvyszkcyLJHyqX5AKrBpYqlV9/tVs4Wx7j7Fb97ZLCKjh3DXhBqRGLRFZQHudxFU+L4GTmP5miOUWBjG5rtl/PgFHAXe7EXEcq/ZhmGemLbvf0vpgxCiPf8XuCMYaHHFEvibqXvK7FbVBP9wcjngymTCjlACg8AEd6yLDtz1P7H9b4yiWjck9t5IR1ZZO5nQ5/QEj3Qg+KBFmViQ== 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: The compaction result helpers encode quirks that are specific to the allocator's retry logic. E.g. COMPACT_SUCCESS and COMPACT_COMPLETE actually represent failures that should be retried upon, and so on. I frequently found myself pulling up the helper implementation in order to understand and work on the retry logic. They're not quite clean abstractions; rather they split the retry logic into two locations. Remove the helpers and inline the checks. Then comment on the result interpretations directly where the decision making happens. Signed-off-by: Johannes Weiner Acked-by: Vlastimil Babka --- include/linux/compaction.h | 92 ---------------------------------- include/trace/events/mmflags.h | 4 +- mm/page_alloc.c | 30 ++++++----- 3 files changed, 19 insertions(+), 107 deletions(-) diff --git a/include/linux/compaction.h b/include/linux/compaction.h index a6e512cfb670..1f0328a2ba48 100644 --- a/include/linux/compaction.h +++ b/include/linux/compaction.h @@ -95,78 +95,6 @@ extern enum compact_result compaction_suitable(struct zone *zone, int order, extern void compaction_defer_reset(struct zone *zone, int order, bool alloc_success); -/* Compaction has made some progress and retrying makes sense */ -static inline bool compaction_made_progress(enum compact_result result) -{ - /* - * Even though this might sound confusing this in fact tells us - * that the compaction successfully isolated and migrated some - * pageblocks. - */ - if (result == COMPACT_SUCCESS) - return true; - - return false; -} - -/* Compaction has failed and it doesn't make much sense to keep retrying. */ -static inline bool compaction_failed(enum compact_result result) -{ - /* All zones were scanned completely and still not result. */ - if (result == COMPACT_COMPLETE) - return true; - - return false; -} - -/* Compaction needs reclaim to be performed first, so it can continue. */ -static inline bool compaction_needs_reclaim(enum compact_result result) -{ - /* - * Compaction backed off due to watermark checks for order-0 - * so the regular reclaim has to try harder and reclaim something. - */ - if (result == COMPACT_SKIPPED) - return true; - - return false; -} - -/* - * Compaction has backed off for some reason after doing some work or none - * at all. It might be throttling or lock contention. Retrying might be still - * worthwhile, but with a higher priority if allowed. - */ -static inline bool compaction_withdrawn(enum compact_result result) -{ - /* - * If compaction is deferred for high-order allocations, it is - * because sync compaction recently failed. If this is the case - * and the caller requested a THP allocation, we do not want - * to heavily disrupt the system, so we fail the allocation - * instead of entering direct reclaim. - */ - if (result == COMPACT_DEFERRED) - return true; - - /* - * If compaction in async mode encounters contention or blocks higher - * priority task we back off early rather than cause stalls. - */ - if (result == COMPACT_CONTENDED) - return true; - - /* - * Page scanners have met but we haven't scanned full zones so this - * is a back off in fact. - */ - if (result == COMPACT_PARTIAL_SKIPPED) - return true; - - return false; -} - - bool compaction_zonelist_suitable(struct alloc_context *ac, int order, int alloc_flags); @@ -185,26 +113,6 @@ static inline enum compact_result compaction_suitable(struct zone *zone, int ord return COMPACT_SKIPPED; } -static inline bool compaction_made_progress(enum compact_result result) -{ - return false; -} - -static inline bool compaction_failed(enum compact_result result) -{ - return false; -} - -static inline bool compaction_needs_reclaim(enum compact_result result) -{ - return false; -} - -static inline bool compaction_withdrawn(enum compact_result result) -{ - return true; -} - static inline void kcompactd_run(int nid) { } diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h index b63e7c0fbbe5..1478b9dd05fa 100644 --- a/include/trace/events/mmflags.h +++ b/include/trace/events/mmflags.h @@ -223,8 +223,8 @@ IF_HAVE_VM_SOFTDIRTY(VM_SOFTDIRTY, "softdirty" ) \ #define compact_result_to_feedback(result) \ ({ \ enum compact_result __result = result; \ - (compaction_failed(__result)) ? COMPACTION_FAILED : \ - (compaction_withdrawn(__result)) ? COMPACTION_WITHDRAWN : COMPACTION_PROGRESS; \ + (__result == COMPACT_COMPLETE) ? COMPACTION_FAILED : \ + (__result == COMPACT_SUCCESS) ? COMPACTION_PROGRESS : COMPACTION_WITHDRAWN; \ }) #define COMPACTION_FEEDBACK \ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 47421bedc12b..5a84a0bebc37 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3768,35 +3768,39 @@ should_compact_retry(struct alloc_context *ac, int order, int alloc_flags, if (fatal_signal_pending(current)) return false; - if (compaction_made_progress(compact_result)) + /* + * Compaction managed to coalesce some page blocks, but the + * allocation failed presumably due to a race. Retry some. + */ + if (compact_result == COMPACT_SUCCESS) (*compaction_retries)++; /* - * compaction considers all the zone as desperately out of memory - * so it doesn't really make much sense to retry except when the + * All zones were scanned completely and still no result. It + * doesn't really make much sense to retry except when the * failure could be caused by insufficient priority */ - if (compaction_failed(compact_result)) + if (compact_result == COMPACT_COMPLETE) goto check_priority; /* - * compaction was skipped because there are not enough order-0 pages - * to work with, so we retry only if it looks like reclaim can help. + * Compaction was skipped due to a lack of free order-0 + * migration targets. Continue if reclaim can help. */ - if (compaction_needs_reclaim(compact_result)) { + if (compact_result == COMPACT_SKIPPED) { ret = compaction_zonelist_suitable(ac, order, alloc_flags); goto out; } /* - * make sure the compaction wasn't deferred or didn't bail out early - * due to locks contention before we declare that we should give up. - * But the next retry should use a higher priority if allowed, so - * we don't just keep bailing out endlessly. + * If compaction backed due to being deferred, due to + * contended locks in async mode, or due to scanners meeting + * after a partial scan, retry with increased priority. */ - if (compaction_withdrawn(compact_result)) { + if (compact_result == COMPACT_DEFERRED || + compact_result == COMPACT_CONTENDED || + compact_result == COMPACT_PARTIAL_SKIPPED) goto check_priority; - } /* * !costly requests are much more important than __GFP_RETRY_MAYFAIL From patchwork Fri May 19 12:39:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 13248284 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 0BC9BC77B7F for ; Fri, 19 May 2023 12:40:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 081A3900007; Fri, 19 May 2023 08:40:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EBD97900003; Fri, 19 May 2023 08:40:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6592900008; Fri, 19 May 2023 08:40:12 -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 C2C21900003 for ; Fri, 19 May 2023 08:40:12 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7E77A120A64 for ; Fri, 19 May 2023 12:40:12 +0000 (UTC) X-FDA: 80806962264.23.1E2D5EE Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by imf21.hostedemail.com (Postfix) with ESMTP id 976551C0007 for ; Fri, 19 May 2023 12:40:10 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=sb6jjHiP; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf21.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.218.45 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684500010; h=from:from:sender: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=KcIbsIikfDMuopSmhbHndV34wIxjpvvu7t5RPKLo+Ds=; b=sxjjNkVjfsH2AuFcJP9lHHHOm+iKx4hPduUkYCUwMaYB4TBtWlu0xPsvJRemjnO5gr1aeL XNMM48OEDrnokoTN2oDU2XCrvMPJt5jJ4UcPkcMTppwvn2flwU2LYJ6dETkrMenQgPlw2B 2H8XK5xggiAT4RyR/9AyoXnabFWB0Y8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=sb6jjHiP; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf21.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.218.45 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684500010; a=rsa-sha256; cv=none; b=FEMjKzHp/uPzJx4LzIvfSthBL+r9x/4iBgzEQEvXFMdlx/qNqb/CXc2Nppc70K235BFVil eB6D0GgkE010fagQQuexwtHY4zn25gXqqjhstPiz35ki0oz6U8tCzR1ReV5gCQVNpmXqGX hBzAa5b+uVFUfG8mznPCU/emCd41828= Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-96f7377c86aso77298066b.1 for ; Fri, 19 May 2023 05:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20221208.gappssmtp.com; s=20221208; t=1684500009; x=1687092009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KcIbsIikfDMuopSmhbHndV34wIxjpvvu7t5RPKLo+Ds=; b=sb6jjHiPTREDcXdqa2JjB543aE4BffIZF/xpQ81XMOPbM5HDi7RIw/E2nSt+nx319g gPJgXd5jWMC7y6+vkLqrHE+0zbFS3gbHUeppbPpBCiBAohfGYKUfPFayPpzAob9UXhxE QEegswrzo+Jdcji9zBexb7zusPe6L0fKPR2rbjXa/EhMVS7NUITvoive3AA6Xwbeno+A CwED3HrTiR3swlcHMBb0od8FoLayohcwFMLmKVO2c2Y2qhgfs87pyMfAMwlsVGKgzU0o AYN8sqSYl+atdFoHRcFi2lu+/nsFdkF/r6TrTSzeUZT2EACdDjtMk4pC+XdWoe8U+5xo fkVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684500009; x=1687092009; h=content-transfer-encoding:mime-version: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=KcIbsIikfDMuopSmhbHndV34wIxjpvvu7t5RPKLo+Ds=; b=GgY8urojqJo3wk4YMp/Z4RR3HVZNfQwL1BKIjsfgoND61UcpczRtH/KL7fpnaS0R5z W92t+bZ3kJ29x5OAgnvB6GNDk9Zyc/d+EAKICOdLk8/FwWcmd05BxkWt8oMZUsmPejpb 4BhE61/tC4T7+fPy0Vf9uwyTVhYU6D3DoXbpwUxj9PFp/6nHLAUsogY0JLAa9IIf9naV 1IurwBm9zBfxwPFwM3S8qPLQXGjJ5Fi2YDgiTSccvf5bLdJjWu8yw8hqQL54/Eq0HNUY dGtbkm8bx7P0Wo+rVki6457Lz10ZI5Y09LhuO6bsb3TCsZFCKwdThZQ4rbC5AMBVqGPR U1vw== X-Gm-Message-State: AC+VfDxdc3Nxnto2kCHyjosUEmwMp56eQzKCa6a4ILAMsfxOZwI67lpH i31Nwx2cUSPfZ/ahFxEMRqaD3Q== X-Google-Smtp-Source: ACHHUZ42BThcRQN7iBlCrc1jrTpTmxdOBr2VDl2uvIRk1Qsm8fZ7lS6NcIBzfFWtNzJJ8hIX2xrwWg== X-Received: by 2002:a17:907:1c0e:b0:969:dda1:3896 with SMTP id nc14-20020a1709071c0e00b00969dda13896mr2224646ejc.0.1684500009025; Fri, 19 May 2023 05:40:09 -0700 (PDT) Received: from localhost ([2a02:8070:6389:7d40:e266:3092:9afb:a7b1]) by smtp.gmail.com with ESMTPSA id l18-20020a170906a41200b00965a52d2bf6sm2253368ejz.88.2023.05.19.05.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 05:40:08 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Mel Gorman , Vlastimil Babka , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 2/5] mm: compaction: simplify should_compact_retry() Date: Fri, 19 May 2023 14:39:56 +0200 Message-Id: <20230519123959.77335-3-hannes@cmpxchg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230519123959.77335-1-hannes@cmpxchg.org> References: <20230519123959.77335-1-hannes@cmpxchg.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 976551C0007 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: fs9yq8k95ghhkzeft5aoo8dbuugbw6dn X-HE-Tag: 1684500010-572992 X-HE-Meta: U2FsdGVkX18Yq/5iM3nMSTirEVDOiV5pxwCUBXwArlf9YdIMTcKwMZnG+51jjbmpX8QbV9gWXZm+ERxTo1joEcYedKTUXEtKXqmlnHq3sOKePjPAj2KSNZpWMXmvrdtmzgpVukJv+XZQtroiRHgyIQ9AUNfFNJwj9CwRhrmLOuRVeheRCTTgAy2LAV5lVu02hCNmMtBOJCad2Rk50y+JY0uAVHQf7KVZSTrSHlKfqzOEL1jR60QwMxPGR6RcKHP8g9O4+N83quDGfkKKbi3uR7DztW28EGDLKbWYzHPU/iHHt/4h2eCKm9GFptySRmgnDJotCiVZQEIuplnBMrP8qescO4VXfBbWIjyKN7IHn2vDhOOpZ1p5z/FbbSvnzxneJn+qhuRNRX/pA7vpWFo2QKEirPxugCpW+zXwwJhBSho2wTM9eO44/aDdfJjoYla8K1CUWz9g+Jyt6AKWtwUAl4N111bltfnTET+OPBDTTydcJ8KeifCDENFMpTaYst3ERS5f7DY6DJMTpo7H0DSC1EYhlN0q4yJPw9R+IVyJ7SbU6Nb6FsvSXXWqfjuWZ5AbBlAWuCPqQh0sghJl8+rybB01RYa0szVgTe9WZYJywNFNlR8u9k5tR5Zt/hqPtAwPHzEqP0LIqLIwC6SabRy9H+vZHCtOodlY2BRXM001Wc551QEv/ETY8OTe962mXMYXomjCa4aTg5QOlC9qb+WNT4SR7GM3oJYK+Z1srfJjYocXn9ptcAP6rn0B5rC4SZp293t/783l0OrEFuBneshAscCLGmr5DOKeJraRxupXcxY8Do1huK7xE7o8cGypjHzYQFuaJm71UW8pP/2ytgm3ayvWeUGLFXIZOKS+AV8g3WLOVY4TNKpiJSh4jC0E1elmjHf1rCMMcGez+zCjbCwAwNBN6nWWVrIKT8Rg22ATqDsUZ/Reu6XJVmfFEmtCH97xsQZdZRxP+WKC1yyhCmg YS0cwtyz Z89zxd8OnXxtqVWJsbLg9ahzEglt0LN9vwTgu0MWI4yRqHjVeZelnVuQ6fPtptSnBYiBVIybScjOBIXG76QbO6AVdi/uD5ORlsWNKjDzKMziS6GrQzTBoJWiYN+jHeIAoCCj+e0o53uxulKlsHk4H/PQeSqN8a9x2thhjdxmVZUkm73NWyjpCdXySlf3kFiPjj6tAxV6kFtArE14E+xewRJQiiBVLnq5mVQPx2wwoZdqDlmBnKlcGcO9jUAZt/c49OSWIdxrRWUnDawT7yBoSi5iGz1X+SE7PQcx/J68Wp+b2lSQEMwGNuiYHX8orSpEtTiA5PxsYbcpQol4whTYZVcS5UDJ9b0a4OL37TsKkWIjDZ4lABIXWQBU8iYNK28hc9KPGGrrT6czhpFNZfJbRDF9VfsvsmXiG7sQ2b62k3ma0yAn86IyFwoUj1lAXxjprLASywAZZmFnG3azwPlKRyFV3D/U2HpoBgkBpasHJb6U6lmkcAK0GJ8J2mWxNPTq5gMrG4+GiR0McQIU= 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: The different branches for retry are unnecessarily complicated. There are really only three outcomes: progress (retry n times), skipped (retry if reclaim can help), failed (retry with higher priority). Rearrange the branches and the retry counter to make it simpler. v2: - fix trace point build (Mel) - fix max_retries logic for costly allocs (Huang) Signed-off-by: Johannes Weiner --- mm/page_alloc.c | 53 +++++++++++++++---------------------------------- 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 5a84a0bebc37..72660e924b95 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3772,16 +3772,22 @@ should_compact_retry(struct alloc_context *ac, int order, int alloc_flags, * Compaction managed to coalesce some page blocks, but the * allocation failed presumably due to a race. Retry some. */ - if (compact_result == COMPACT_SUCCESS) - (*compaction_retries)++; + if (compact_result == COMPACT_SUCCESS) { + /* + * !costly requests are much more important than + * __GFP_RETRY_MAYFAIL costly ones because they are de + * facto nofail and invoke OOM killer to move on while + * costly can fail and users are ready to cope with + * that. 1/4 retries is rather arbitrary but we would + * need much more detailed feedback from compaction to + * make a better decision. + */ + if (order > PAGE_ALLOC_COSTLY_ORDER) + max_retries /= 4; - /* - * All zones were scanned completely and still no result. It - * doesn't really make much sense to retry except when the - * failure could be caused by insufficient priority - */ - if (compact_result == COMPACT_COMPLETE) - goto check_priority; + ret = ++(*compaction_retries) <= max_retries; + goto out; + } /* * Compaction was skipped due to a lack of free order-0 @@ -3793,35 +3799,8 @@ should_compact_retry(struct alloc_context *ac, int order, int alloc_flags, } /* - * If compaction backed due to being deferred, due to - * contended locks in async mode, or due to scanners meeting - * after a partial scan, retry with increased priority. - */ - if (compact_result == COMPACT_DEFERRED || - compact_result == COMPACT_CONTENDED || - compact_result == COMPACT_PARTIAL_SKIPPED) - goto check_priority; - - /* - * !costly requests are much more important than __GFP_RETRY_MAYFAIL - * costly ones because they are de facto nofail and invoke OOM - * killer to move on while costly can fail and users are ready - * to cope with that. 1/4 retries is rather arbitrary but we - * would need much more detailed feedback from compaction to - * make a better decision. - */ - if (order > PAGE_ALLOC_COSTLY_ORDER) - max_retries /= 4; - if (*compaction_retries <= max_retries) { - ret = true; - goto out; - } - - /* - * Make sure there are attempts at the highest priority if we exhausted - * all retries or failed at the lower priorities. + * Compaction failed. Retry with increasing priority. */ -check_priority: min_priority = (order > PAGE_ALLOC_COSTLY_ORDER) ? MIN_COMPACT_COSTLY_PRIORITY : MIN_COMPACT_PRIORITY; From patchwork Fri May 19 12:39:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 13248285 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 C918CC7EE23 for ; Fri, 19 May 2023 12:40:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0659D900008; Fri, 19 May 2023 08:40:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0183A900003; Fri, 19 May 2023 08:40:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAA1A900008; Fri, 19 May 2023 08:40:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C9BDA900003 for ; Fri, 19 May 2023 08:40:13 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9F1C8160110 for ; Fri, 19 May 2023 12:40:13 +0000 (UTC) X-FDA: 80806962306.14.6F926DE Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) by imf28.hostedemail.com (Postfix) with ESMTP id 9EFE2C000F for ; Fri, 19 May 2023 12:40:11 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=j8nprdhT; spf=pass (imf28.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.218.43 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684500011; a=rsa-sha256; cv=none; b=A0FENVKup280g3FJUgBHHncxrIMhZJroLUwoKDUZzEuBvG1CaAx1XVBsRAq1FXQvSuLtNS KUH3ysxM/NJ225cQKGf9AFIlyfMl/8xu7ZUdd5tLm8giIyegUATU7N4ZqU1RSVDY6F5ybX Td/estnNhcmS+eJExnvxtL9aJa/Ge/4= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=j8nprdhT; spf=pass (imf28.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.218.43 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684500011; h=from:from:sender: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=vXkGmoOKMV9wp5TM6FJc6/QwLR/CY7AZ1q5R5QORiXk=; b=wVHXSVIEeC7jepoUkseepA6x1IAaV23SuRTLE1ZiQbC0WGK6GfAPTNXbUGerdPd42Wjq7o 4Vfnhob4I555/TK/1XPIFgjVSWOPMfH7aag+c1Z1ylGl7+Y5swzE9yL0/5Q+XwCHyIvexK ejhB3OBVQJQWc3OCZwD0RM7XrmQaE0E= Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-94a342f7c4cso610442066b.0 for ; Fri, 19 May 2023 05:40:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20221208.gappssmtp.com; s=20221208; t=1684500010; x=1687092010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vXkGmoOKMV9wp5TM6FJc6/QwLR/CY7AZ1q5R5QORiXk=; b=j8nprdhTRVRZX+b+MiJ39vvsPB8y0GGrbPhI6lsexF0dvkO4amR6WItiuegG9BfiRU MN8A49KVx8o86hTYpRXpcGjnSKD25lzyyj/NH4c3kzpIu8FH29Fwu9YXWODBkI/cR2tZ tOWDqP3eVUjsGYrXv9d6xlJKrPpVGZlF4AoFmjHQ8nIIaKIWelJHj4SHtHzvkTfTetw7 uwZhgOO/hTAb8A1ZkSqmIj2ZGQM1X+5/b7c6kdyR6bMbj9hfiKlwreo9cF2y7+qx1WJD 81n9YGKCYvomlnft2jGfo59NweehDvgmGgPIPXd9/QQdknjD+xJPIaq182eUfreAbQ8C sHmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684500010; x=1687092010; h=content-transfer-encoding:mime-version: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=vXkGmoOKMV9wp5TM6FJc6/QwLR/CY7AZ1q5R5QORiXk=; b=UOMhBwyjc9jRTDGG8KjUyO81bg2bezQCTdgkfLjEYOIihPeqTuYmTTiX8ANtugzE5E XcdzFs92hE6vGJknxl38hjhpwY3bOXEfmOR0xrhjzchVli8WAPP/y0l1L5XKFrMsHJsh u6FIkK0vC6hx/zn5c0NHrtHoDrTXEa94qgQ/sL+MxR84H/KFXP6+f/RuZIuEcFudYlKU SiQDL/e9AING5n/LWc4ae+O9Vem7dLUBHGWAYPfqxpftwn/MCNq+wv+x4fCNWqkcj7Fg e9Zwv2SOxlzlseo1XLi1vC/Q+X/lxvTGv1duVBFB0OAZ4zSZS2zO/vZtJrc/qOhpSszO tDyw== X-Gm-Message-State: AC+VfDw1uGdMhuTIK1Y3kSqxha8gvsvOFJ3/nHCK8yqK7fFpdSkicYRs Idq5kp723Zj8+vurnvY/G/poRQ== X-Google-Smtp-Source: ACHHUZ5OI99u6ZjRHk2L81FZPXX2dcOxJ0p3S0XoqUDF0BmNWfVXDxnHp4ONjafiSuyLZ1d4i1Us2w== X-Received: by 2002:a17:906:ee88:b0:94a:5819:5a2b with SMTP id wt8-20020a170906ee8800b0094a58195a2bmr1567192ejb.33.1684500010022; Fri, 19 May 2023 05:40:10 -0700 (PDT) Received: from localhost ([2a02:8070:6389:7d40:e266:3092:9afb:a7b1]) by smtp.gmail.com with ESMTPSA id u20-20020a170906125400b009571293d6acsm2236343eja.59.2023.05.19.05.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 05:40:09 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Mel Gorman , Vlastimil Babka , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 3/5] mm: compaction: refactor __compaction_suitable() Date: Fri, 19 May 2023 14:39:57 +0200 Message-Id: <20230519123959.77335-4-hannes@cmpxchg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230519123959.77335-1-hannes@cmpxchg.org> References: <20230519123959.77335-1-hannes@cmpxchg.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 9EFE2C000F X-Stat-Signature: c84wffxgoqb37ioykch3kh8hnsbz1cp8 X-Rspam-User: X-HE-Tag: 1684500011-173792 X-HE-Meta: U2FsdGVkX1/10FeCXYpLZiWdarHOacdbXVbFt+0UGlWg4KOcnRpJMqtiFgHtJQwFFSDTd0+52wMEIpVAr/WTAcDzIarq5Wi7J9eBIddvgSyU3uGwg4n4hzfwVfk9mtzz+wZGjCVpcl94I5SdrPflMuq1mLG6EBK6kJyrjPuqZ21I/r5kacW+8SGltVVmXOmXdbUYiLad2iDV43QsJwx/qXDjXRm5zPAVsUlKU/xl6hbAG/vWZ4W6dSKKcqYtTMUsHnpyglI6yxCBOTaKKStj99r94OvDi4mVTBmdq7z6sdWGb5AEyc/lphxH/l0hO5f9ogZqgfoF5oAqHrDz/HZIvCq76KXd7XBjmDyMFE5B/fWWwSxphbonAYlcMYfUlSizDc6SxlX7D+vr/qOAbuoXr/okbeTdG7oFflbmyC4CL7XvhAEjDsqsifrjmYRrVTbL5vh5fAJEQQwqNrwpn+snEkWsO68RTyY/d4+XL/B7DHQlrPalPifXvIalSPTQAnMEAbSSstGKSHLPWgUsNOwECEukGsGWouV7Wqo2YtagoUfoyQeCKW2B34u3jKfTqKlVy+T669RzLEc5GUhepummqlExAV6CZ2Bp3ZT+3BxfVfvZ4lCWAU+T4Sy6YIQMnnwtXtDxavvQMyo0bKoSyjPf3tXfz72xPSJJxfTrbKqztT6RazscHmYQNgfwq/QT3L+5mjyrlwMjdWCWsk3u+WEdGvIh8bfTBDlPgM7rLEDxRBiA9UeXGIEUXz3Q9JwGCaHhTMvm/LGQQSs7czgN4+Fpr7vhc0TYb5rIMYkCfmrahgdVznIgpu8oZujtBL7fMwBsUA9NIe9KWjnT65zimvV3pB4hzBAnD93pdCgtAck0y9vRYCDqZbAfbAN9ZkfliBnF5b4fVCydR9UjkRIosqymBmFfvAkTvOjnTjzA+HFa+LvrqUs6xK7ulBy9csBz2/cY/ys5twOH44RcscXPhB5 x19SuGGK nowDIc8a1S9tsmMi/XlIihwhixyKOsblXhbqXRNf2apD8nYRE4coHSA1bhJfk8haM3lz0HifY9vmd4sSuynuk3Rn/5QDx13Mdg9DN6bAANpHGLnJnP3t4uRRCzmCjmtwpp5B7gKkrnuOE5g6skC/a0h26w4m0dhy0j5w3lnJ/JRVh2x+YpYD7JL/u38Uc612LFXKwrtv1jLgCmdDtwOdz6HoG8aPwQMJWRDk8f39hvUBjVSIgy04ZJBsjZqwlPa0UL+MBSAB6tfRqbYx53Om+IzbUtWxmnNqT1ajnZOvlWWIAhm6JMOQ6KjrOLKP7hVmOlK3VaB2/myYHK7iZrI7DX2zO/qkIRumvf1gUKB1QhDKgb3UTXca5lr4GArN0im1XsZMfbIaVfYtO1JhtZpJN98STAJDpbvUDIJYe0PNj84aqvFh3/0WgSEQJsBxxp0xXWsd45W7eyai+HR6oVroa3dnAQMXg03dmK07uJcva63H/L/QyAmMAlsDpEtE8mzuLPNi9cG37nqag/ng= 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: __compaction_suitable() is supposed to check for available migration targets. However, it also checks whether the operation was requested via /proc/sys/vm/compact_memory, and whether the original allocation request can already succeed. These don't apply to all callsites. Move the checks out to the callers, so that later patches can deal with them one by one. No functional change intended. Signed-off-by: Johannes Weiner Acked-by: Vlastimil Babka --- include/linux/compaction.h | 4 +- mm/compaction.c | 78 ++++++++++++++++++++++++-------------- mm/vmscan.c | 35 ++++++++++------- 3 files changed, 73 insertions(+), 44 deletions(-) diff --git a/include/linux/compaction.h b/include/linux/compaction.h index 1f0328a2ba48..9f7cf3e1bf89 100644 --- a/include/linux/compaction.h +++ b/include/linux/compaction.h @@ -90,7 +90,7 @@ extern enum compact_result try_to_compact_pages(gfp_t gfp_mask, struct page **page); extern void reset_isolation_suitable(pg_data_t *pgdat); extern enum compact_result compaction_suitable(struct zone *zone, int order, - unsigned int alloc_flags, int highest_zoneidx); + int highest_zoneidx); extern void compaction_defer_reset(struct zone *zone, int order, bool alloc_success); @@ -108,7 +108,7 @@ static inline void reset_isolation_suitable(pg_data_t *pgdat) } static inline enum compact_result compaction_suitable(struct zone *zone, int order, - int alloc_flags, int highest_zoneidx) + int highest_zoneidx) { return COMPACT_SKIPPED; } diff --git a/mm/compaction.c b/mm/compaction.c index c9a4b6dffcf2..8f61cfa87c49 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2206,24 +2206,10 @@ static enum compact_result compact_finished(struct compact_control *cc) } static enum compact_result __compaction_suitable(struct zone *zone, int order, - unsigned int alloc_flags, int highest_zoneidx, unsigned long wmark_target) { unsigned long watermark; - - if (is_via_compact_memory(order)) - return COMPACT_CONTINUE; - - watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK); - /* - * If watermarks for high-order allocation are already met, there - * should be no need for compaction at all. - */ - if (zone_watermark_ok(zone, order, watermark, highest_zoneidx, - alloc_flags)) - return COMPACT_SUCCESS; - /* * Watermarks for order-0 must be met for compaction to be able to * isolate free pages for migration targets. This means that the @@ -2256,13 +2242,12 @@ static enum compact_result __compaction_suitable(struct zone *zone, int order, * COMPACT_CONTINUE - If compaction should run now */ enum compact_result compaction_suitable(struct zone *zone, int order, - unsigned int alloc_flags, int highest_zoneidx) { enum compact_result ret; int fragindex; - ret = __compaction_suitable(zone, order, alloc_flags, highest_zoneidx, + ret = __compaction_suitable(zone, order, highest_zoneidx, zone_page_state(zone, NR_FREE_PAGES)); /* * fragmentation index determines if allocation failures are due to @@ -2306,7 +2291,16 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, for_each_zone_zonelist_nodemask(zone, z, ac->zonelist, ac->highest_zoneidx, ac->nodemask) { unsigned long available; - enum compact_result compact_result; + unsigned long watermark; + + if (is_via_compact_memory(order)) + return true; + + /* Allocation can already succeed, nothing to do */ + watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK); + if (zone_watermark_ok(zone, order, watermark, + ac->highest_zoneidx, alloc_flags)) + continue; /* * Do not consider all the reclaimable memory because we do not @@ -2316,9 +2310,8 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, */ available = zone_reclaimable_pages(zone) / order; available += zone_page_state_snapshot(zone, NR_FREE_PAGES); - compact_result = __compaction_suitable(zone, order, alloc_flags, - ac->highest_zoneidx, available); - if (compact_result == COMPACT_CONTINUE) + if (__compaction_suitable(zone, order, ac->highest_zoneidx, + available) == COMPACT_CONTINUE) return true; } @@ -2348,11 +2341,23 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) INIT_LIST_HEAD(&cc->migratepages); cc->migratetype = gfp_migratetype(cc->gfp_mask); - ret = compaction_suitable(cc->zone, cc->order, cc->alloc_flags, - cc->highest_zoneidx); - /* Compaction is likely to fail */ - if (ret == COMPACT_SUCCESS || ret == COMPACT_SKIPPED) - return ret; + + if (!is_via_compact_memory(cc->order)) { + unsigned long watermark; + + /* Allocation can already succeed, nothing to do */ + watermark = wmark_pages(cc->zone, + cc->alloc_flags & ALLOC_WMARK_MASK); + if (zone_watermark_ok(cc->zone, cc->order, watermark, + cc->highest_zoneidx, cc->alloc_flags)) + return COMPACT_SUCCESS; + + ret = compaction_suitable(cc->zone, cc->order, + cc->highest_zoneidx); + /* Compaction is likely to fail */ + if (ret == COMPACT_SKIPPED) + return ret; + } /* * Clear pageblock skip if there were failures recently and compaction @@ -2845,7 +2850,16 @@ static bool kcompactd_node_suitable(pg_data_t *pgdat) if (!populated_zone(zone)) continue; - if (compaction_suitable(zone, pgdat->kcompactd_max_order, 0, + if (is_via_compact_memory(pgdat->kcompactd_max_order)) + return true; + + /* Allocation can already succeed, check other zones */ + if (zone_watermark_ok(zone, pgdat->kcompactd_max_order, + min_wmark_pages(zone), + highest_zoneidx, 0)) + continue; + + if (compaction_suitable(zone, pgdat->kcompactd_max_order, highest_zoneidx) == COMPACT_CONTINUE) return true; } @@ -2883,10 +2897,18 @@ static void kcompactd_do_work(pg_data_t *pgdat) if (compaction_deferred(zone, cc.order)) continue; - if (compaction_suitable(zone, cc.order, 0, zoneid) != - COMPACT_CONTINUE) + if (is_via_compact_memory(cc.order)) + goto compact; + + /* Allocation can already succeed, nothing to do */ + if (zone_watermark_ok(zone, cc.order, + min_wmark_pages(zone), zoneid, 0)) continue; + if (compaction_suitable(zone, cc.order, + zoneid) != COMPACT_CONTINUE) + continue; +compact: if (kthread_should_stop()) return; diff --git a/mm/vmscan.c b/mm/vmscan.c index d257916f39e5..c9c0f3e081f5 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -6397,14 +6397,17 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat, if (!managed_zone(zone)) continue; - switch (compaction_suitable(zone, sc->order, 0, sc->reclaim_idx)) { - case COMPACT_SUCCESS: - case COMPACT_CONTINUE: + if (sc->order == -1) /* is_via_compact_memory() */ + return false; + + /* Allocation can already succeed, nothing to do */ + if (zone_watermark_ok(zone, sc->order, min_wmark_pages(zone), + sc->reclaim_idx, 0)) + return false; + + if (compaction_suitable(zone, sc->order, + sc->reclaim_idx) == COMPACT_CONTINUE) return false; - default: - /* check next zone */ - ; - } } /* @@ -6592,16 +6595,20 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc) static inline bool compaction_ready(struct zone *zone, struct scan_control *sc) { unsigned long watermark; - enum compact_result suitable; - suitable = compaction_suitable(zone, sc->order, 0, sc->reclaim_idx); - if (suitable == COMPACT_SUCCESS) - /* Allocation should succeed already. Don't reclaim. */ + if (sc->order == -1) /* is_via_compact_memory() */ + goto suitable; + + /* Allocation can already succeed, nothing to do */ + if (zone_watermark_ok(zone, sc->order, min_wmark_pages(zone), + sc->reclaim_idx, 0)) return true; - if (suitable == COMPACT_SKIPPED) - /* Compaction cannot yet proceed. Do reclaim. */ - return false; + /* Compaction cannot yet proceed. Do reclaim. */ + if (compaction_suitable(zone, sc->order, + sc->reclaim_idx) == COMPACT_SKIPPED) + return false; +suitable: /* * Compaction is already possible, but it takes time to run and there * are potentially other callers using the pages just freed. So proceed From patchwork Fri May 19 12:39:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 13248286 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 A2C8FC77B7A for ; Fri, 19 May 2023 12:40:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B624B900009; Fri, 19 May 2023 08:40:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1390900003; Fri, 19 May 2023 08:40:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93D68900009; Fri, 19 May 2023 08:40:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7E9BB900003 for ; Fri, 19 May 2023 08:40:14 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 508871409B5 for ; Fri, 19 May 2023 12:40:14 +0000 (UTC) X-FDA: 80806962348.12.CE3545D Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) by imf13.hostedemail.com (Postfix) with ESMTP id 510822000F for ; Fri, 19 May 2023 12:40:12 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=GT59zzmh; spf=pass (imf13.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.218.43 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684500012; h=from:from:sender: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=I12hzcEozsRt6JPAOpJEFjq1ISq2RgZIT2QaHAH/cww=; b=8Qpog6FnwzbU9E+3KJs8IO2bVybvX2OtjAluSMoMzeZjFQOX5LTmvyln8SPj0whfipgQAP Ns892qpRiKvJs/EwuHs9UonicV5v/qtgO0bp4MdUWRiypMRyZnYjUyO4spxNPqan2r/0Nt 7j72FUTia7azpD72shvZJMrT7/ShxAA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=GT59zzmh; spf=pass (imf13.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.218.43 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684500012; a=rsa-sha256; cv=none; b=hciJ3t65c6Pn8mdo+ho04wBJXwqYm9TSWOUd5bbAy1vUkpog7vbZkYgmfGdeXZGuboCIfj 98A0lHITgTuxD4arO3OAamngqd/iYq0b0wAHRLYy0ydKRHqQOc/yVRHOdxG1Iv2X1WSDdu +zFBgonvNh7zhi+XHJrFp8jVvAFIsnw= Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-94a342f7c4cso610445766b.0 for ; Fri, 19 May 2023 05:40:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20221208.gappssmtp.com; s=20221208; t=1684500011; x=1687092011; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I12hzcEozsRt6JPAOpJEFjq1ISq2RgZIT2QaHAH/cww=; b=GT59zzmhCzWRze5Mlw1ALcSFM9y1f9VU/vsZANEVBYHqrlCkXWWh82A+SSfKkAhcf4 3tQ4UFzmxgxZ15dHaxAEnORekxc5TClUeKGWjmM3kIdHBVyDw4ORdXKtk4UyFNmyLKsx bPrrt63f3L9CI/VluEvxZgTjbObARXFRQrS6O0wUVIlJvsvAh4EhyRGdH/5mzFfSMvAU Ma2idKjNNvoYRHFytUI0nQaXf6rj3SDgQr9NpgZmmj7Yk6zkusJ3ACinYJ0FWUKgb/PF jUETXeREzOwQbPb+s4QGvIlHS2Hg954aU5qGVb5Th2SArEQNshM7l3a3RdF3R0fs+NVo k1Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684500011; x=1687092011; h=content-transfer-encoding:mime-version: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=I12hzcEozsRt6JPAOpJEFjq1ISq2RgZIT2QaHAH/cww=; b=WD7Gilza07g7tiY1siR/j0RkLpgH1RZdmx1k5iQDGEYCi7nV/MvUrjTnoh5gx/7H7/ xkHbi8HhjsL/sm9K0z6ETE36nxCiqVt6Lr3Tp3RgBe0hzYPKHRgGHzX8nmC91R94royy McXh7Egkje7YzVIH7JL+OEQf8JZ+dn2Kh7wDhakg6O+BmMNma/rkLRFsXJw7ZwJiyfJ2 M9PsrwqZUMMAuwuq4OjSJkgt0Gn1dSu3wzlg1yjGwevJAVWXtZZpbRwy07ajl6zz5Jmo bIHR5DIEbRF/O6b0ofcy/aEmlm6LNArjphga6dScVGIhzXOZVV0SZkUTUOFFCo3fmztJ cW2Q== X-Gm-Message-State: AC+VfDzIBgcZFuZeo0c5kWcw5++jgFSxAFiIaaqYak8uu9Zb0QVcSOnU srgceHDinEVr65KgQWZAGNXTbQ== X-Google-Smtp-Source: ACHHUZ4u90+qy6wcMhun2oAgrbOIc2XjLRHqEiy1bSQkvwbZrSERksL8jCVIYbiTqqILkLPHJwuusA== X-Received: by 2002:a17:907:5c7:b0:96a:ed6e:7d58 with SMTP id wg7-20020a17090705c700b0096aed6e7d58mr1561004ejb.7.1684500010821; Fri, 19 May 2023 05:40:10 -0700 (PDT) Received: from localhost ([2a02:8070:6389:7d40:e266:3092:9afb:a7b1]) by smtp.gmail.com with ESMTPSA id q26-20020a170906145a00b00966069b78absm2236221ejc.192.2023.05.19.05.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 05:40:10 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Mel Gorman , Vlastimil Babka , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 4/5] mm: compaction: remove unnecessary is_via_compact_memory() checks Date: Fri, 19 May 2023 14:39:58 +0200 Message-Id: <20230519123959.77335-5-hannes@cmpxchg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230519123959.77335-1-hannes@cmpxchg.org> References: <20230519123959.77335-1-hannes@cmpxchg.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 510822000F X-Rspam-User: X-Stat-Signature: 9enbmey94sry9dkip5dmox858aiogkbk X-Rspamd-Server: rspam01 X-HE-Tag: 1684500012-220759 X-HE-Meta: U2FsdGVkX183f04ztqcrjl21pyW9/24Co0Hv2To/dirqVLbJEx7nAA76wEur2/X1U9mXhnvP5akhEu3lgGmGYh+oy1ATREjRysOcnzLjfbjLgwPZhOfkWX4qOZKGM+/pPXMlUGssbynJV9Kki6TtmtMt1/KzGkVvHyLKiAWCZYMoVtDNxFDjMzLBr4DxzGFxTXTz5u7Ew5huRugghydiTCG9kD//WTCDLzzsyrEDxMgw2bTo8NEPXf/eG29WI5KhCEirzwaMypSjD+gGOL60z3okmXZopWmlnWWfGME9Tsy3Ci4Et7JOXbvm7Eaim/HlO+ADqerQLzzXDh9l28yQuJALuRR7ZTBGat72LSTqvnYCCHEO+jbYdjfrnTVf2bNjzCE6LINhzK4rKarzcIGLTpd89Dr0/Nr5D6Y6bKLmgEgQuQPH27cCUuGSLs6peuYuO7k0rIVpsaxes393GehyplaVBIUPUwi3sPSSiX/yk3s2HDAL8LCjWxPig/i2BdXrvZKEL74SU6rrVB5hE83p0D/U+4mfFxVzuv0ZnpUNFRrtJpfTCumrluag5zsyKpU0Y+LM7TtEauVJnEqAFAtQU0LgVBzA866ORcNvSXtydKmgRSuVzXUXag5KafT9vLcWWsmLO8CopeM5FsBYT7MvbffUBAxeXWNAhE7c8wR8onLD8AyWlWOFbzADL2qwt5XtPgnqEZhf0JB1b5E1D1e/Sxm2S+VE5XCG2XpID+OoU9nkrYzHElRwgOhNUL9gQKyTbuWdPvn5qb/ydc147zjXy5Hendx+b5PNZRl8gsV357FMnM/1mjYMHdwjloN1geah/MvJ5GeNl+oNy0bbUXVj9blgJe0UxhLYdjUHsdKzIaRgZzruktS4NuGTngx/NVRA8yABfGFkY5xOENe1DVGgkV509fcmnqQCmham9wkDgue5cJWBtDtAhy3ByvtZFcjvL2yPVJG+gqiHm+3nVK5 xcF5Ng0g 6F/0Fpxv82Umm8NUPTLxbXG0dBl7Xp1WCyTW0KP8G1cLRxS3zbi1PgnYUplGo3DX/rPZPy6b/iAXO5ffeYqMBPpEHObDVE5HSBaiIN9VZ+3JCwHUv2ENPr9vz13FzahbS6q3SmNfm36ritH8J6HjVie2N0RNzWdGF+U56VXaVuQEZLeVug4qGHyifpVhrszvViL+X2Zp6qJkUt1to3lF18APfSyp+3cVdYKT3ey+g9l/ubsTNnSRLANuVp+7BDPoEUnXnGqAu5OumrjcaiP9jIT5JB4JvFybk0NJrBF5JceTaTmB5O1P5nI6007slTZmXIuBd9S6ZNYLbk2IwEPLuuiDgc4gz6H9GETeJI1Sb9lTVDrWG1QoawoQ7Wi7B4hl1i6/agb3Jcl+gJwhPC2jo9UBHpD0puJltha357tcgI4jn70q+O83nAjllqQJZQ4XnAvl8bgHAJb+V7MFgeAmDmFXD+BFpMVjIHkClAVy/KYTVIrQ22vU9gvY6K9XSK8ZXWx8+tUyLq+rFJFRt0ku0eqv7jEHNHTjUQKGw03CXPc0zL+C6t6iKXaxHkA== 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: Remove from all paths not reachable via /proc/sys/vm/compact_memory. Signed-off-by: Johannes Weiner Acked-by: Vlastimil Babka --- mm/compaction.c | 11 +---------- mm/vmscan.c | 8 +------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 8f61cfa87c49..83ecbc829c62 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2293,9 +2293,6 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, unsigned long available; unsigned long watermark; - if (is_via_compact_memory(order)) - return true; - /* Allocation can already succeed, nothing to do */ watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK); if (zone_watermark_ok(zone, order, watermark, @@ -2850,9 +2847,6 @@ static bool kcompactd_node_suitable(pg_data_t *pgdat) if (!populated_zone(zone)) continue; - if (is_via_compact_memory(pgdat->kcompactd_max_order)) - return true; - /* Allocation can already succeed, check other zones */ if (zone_watermark_ok(zone, pgdat->kcompactd_max_order, min_wmark_pages(zone), @@ -2897,9 +2891,6 @@ static void kcompactd_do_work(pg_data_t *pgdat) if (compaction_deferred(zone, cc.order)) continue; - if (is_via_compact_memory(cc.order)) - goto compact; - /* Allocation can already succeed, nothing to do */ if (zone_watermark_ok(zone, cc.order, min_wmark_pages(zone), zoneid, 0)) @@ -2908,7 +2899,7 @@ static void kcompactd_do_work(pg_data_t *pgdat) if (compaction_suitable(zone, cc.order, zoneid) != COMPACT_CONTINUE) continue; -compact: + if (kthread_should_stop()) return; diff --git a/mm/vmscan.c b/mm/vmscan.c index c9c0f3e081f5..c0cfa9b86b48 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -6397,9 +6397,6 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat, if (!managed_zone(zone)) continue; - if (sc->order == -1) /* is_via_compact_memory() */ - return false; - /* Allocation can already succeed, nothing to do */ if (zone_watermark_ok(zone, sc->order, min_wmark_pages(zone), sc->reclaim_idx, 0)) @@ -6596,9 +6593,6 @@ static inline bool compaction_ready(struct zone *zone, struct scan_control *sc) { unsigned long watermark; - if (sc->order == -1) /* is_via_compact_memory() */ - goto suitable; - /* Allocation can already succeed, nothing to do */ if (zone_watermark_ok(zone, sc->order, min_wmark_pages(zone), sc->reclaim_idx, 0)) @@ -6608,7 +6602,7 @@ static inline bool compaction_ready(struct zone *zone, struct scan_control *sc) if (compaction_suitable(zone, sc->order, sc->reclaim_idx) == COMPACT_SKIPPED) return false; -suitable: + /* * Compaction is already possible, but it takes time to run and there * are potentially other callers using the pages just freed. So proceed From patchwork Fri May 19 12:39:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 13248287 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 49EAFC7EE23 for ; Fri, 19 May 2023 12:40:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8558D90000A; Fri, 19 May 2023 08:40:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DFA3900003; Fri, 19 May 2023 08:40:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5942290000A; Fri, 19 May 2023 08:40:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 46360900003 for ; Fri, 19 May 2023 08:40:15 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 23E691409DC for ; Fri, 19 May 2023 12:40:15 +0000 (UTC) X-FDA: 80806962390.02.3052624 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by imf14.hostedemail.com (Postfix) with ESMTP id 19302100006 for ; Fri, 19 May 2023 12:40:12 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=20CNqbvJ; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf14.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.218.46 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684500013; h=from:from:sender: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=Z4v+oqRzENdCCjglWNqDJ+55Ca3cK8hCc7vsdYbZrmE=; b=IZ6u6rBB0olUWB8ujQ91tSY/9ERvnsBPyerSE7dcrvYDtjT/evAuiGIWpz1Oe2aws4yw01 dafQ7RVaYiTpURo+P6PmwT/FGlpandihYwtxUe9Azie5+vN5l3IsZ0HMi5s91dyveFYz73 XxIjxOLgjsjG/xM6J80HXesz8bszc2A= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=20CNqbvJ; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf14.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.218.46 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684500013; a=rsa-sha256; cv=none; b=PsCIPDnNugYK66YapEWZIHiSc9lOPNKNEUHHds2JQBOexZnfTj2UbuwirnfnADsD8iUXWe 6XsDI5hQwo3RXC3yJplksFydi5pPwkztWJCWI3pv+R2Jr9TKgFkTcbY0nvujij5SWcxC4s N3qogWVkOknJEnfuaWsNk6182TI/MIw= Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-9659e9bbff5so588761566b.1 for ; Fri, 19 May 2023 05:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20221208.gappssmtp.com; s=20221208; t=1684500011; x=1687092011; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z4v+oqRzENdCCjglWNqDJ+55Ca3cK8hCc7vsdYbZrmE=; b=20CNqbvJsj1aXxY3uCUm45tf9ezX9S2bW71I97+RgtCqHWhejBmT7D8t6SgGPjZ4D0 78NGrpoPPgmK0cvKKi0ScZpI0FqlVDon7QXVVExvNnUuac/erh7fmnnN3w4DhzvLGwft WCQyIYWLBRXqrhGVyJEHXh8X9AnxXKhTN9drGkBpCz7ERqa241WhCyvJ98dXO21xlppI Sen2Lkn8tmpr3cNnF999AOPTRPS/iKGGc5L/ADLTcg86p/eC2uxUGukPE+/gtpo5wxcu PtBvaa/bveFRu5G2nltWcfYX1Yo0Ff93a5HBQCDMqcQ4Ts5TTOtSy8ylgH/sNIc0mkNn i6Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684500011; x=1687092011; h=content-transfer-encoding:mime-version: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=Z4v+oqRzENdCCjglWNqDJ+55Ca3cK8hCc7vsdYbZrmE=; b=cnzl5LnpLh5EScK2r2k3F0w+bRYVCc3KoWKsWulgbyYk1m6Aoy2Ls8Aw70kXAoZYym yREMBid5d79vzXFZvHqi2WRziknBR17QyrGWCr/s3dwfxx9bkVeKGjS0V0WN+RfA6QBY 5Qknm6DMKAajlzqkadD3DKk3z7Uuyxn5KGSPaGwaLb8pmmxlTuVnBqt94ll0AQp8X49M +fsrRxEEWR/QBR8wVXQCz6kJ0pA1e8cweZAxZeMJ+Fz82zc4g21pA+wIEoCKyHHkB+W6 iR6Ho7jvOA2Pd2qlnx22A0ixXGoIb1hxKgIl5EUk0FbK1xYUCT/T8vHlwpNd2n02O/4Q BxpQ== X-Gm-Message-State: AC+VfDyDArxty49/DP1STgKM6rysbyvb8At6Ns45MRoO9wUM4xLrD+gy CsiYZ4iin/3/f272kw4Du18Rrb1o+au386+KL/c= X-Google-Smtp-Source: ACHHUZ5HyrBz4voNu4RQsLSn8EHNU2geTDUc+VN5aCe45DZsHq2yRGRL9hB9xWE6eywvCBf1dsLcEQ== X-Received: by 2002:a17:907:26ca:b0:962:582d:89bf with SMTP id bp10-20020a17090726ca00b00962582d89bfmr1351778ejc.55.1684500011653; Fri, 19 May 2023 05:40:11 -0700 (PDT) Received: from localhost ([2a02:8070:6389:7d40:e266:3092:9afb:a7b1]) by smtp.gmail.com with ESMTPSA id a21-20020a170906191500b0096f7ae359a5sm318552eje.30.2023.05.19.05.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 05:40:11 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Mel Gorman , Vlastimil Babka , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 5/5] mm: compaction: drop redundant watermark check in compaction_zonelist_suitable() Date: Fri, 19 May 2023 14:39:59 +0200 Message-Id: <20230519123959.77335-6-hannes@cmpxchg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230519123959.77335-1-hannes@cmpxchg.org> References: <20230519123959.77335-1-hannes@cmpxchg.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 19302100006 X-Stat-Signature: hr9zyy1by3kg1mydeyj3po6qpsckzxwj X-HE-Tag: 1684500012-611048 X-HE-Meta: U2FsdGVkX18HO12Emo17RuGiqB9EeWuu08ikfMviGYr8oZfzmiim9fKgoFDE24yTl1poRkx7k6ILIm9OFgUUDQK/FwOhIZqMg/zwExPt9Q9pK75VfaJpGXJ6SKBcNyMfF5YZi7cZg0sCh5+crjJVT1uNltTdYvVm4VSzG8/XU9w7MDCXfS0STJr4zdBce2JVsCphjs3nYhLM7eMW9UGn1fBH86JbOlOkOLiVm4fyn65stq9iNcDBtJfkruNHOJe6o2K4mJkhb1RuUxh7Bn3YByJceVzsj8AePfovW5tkDY20Qyfon0OV6rdd/Q9g+wTnOS6rmBqf0XBMUY9+YQFmqMQi/3zTAbs05HvwT4cdJB1rLzf38+TVC8VGwwtMTC51u5Aa8kG++dfVTaMg05ePoNk+ZNK2N/RI0cs2Lfczi0O1D87ITt3EjR6CoZSeA1yvrTVCUkFwXkWBAwuedA7Fa1CuIussIQ2vLvQ4MUSLDQYmSv6J30oo6oCCIZgdH0/7WLF9jE+ksChcH4e1aN7FSZBlWrcE/BRDil4lnYls+P69f4xrE94jIKR/4JfAWNi46GypH+osuwVMX7eArcjSVuZt1309JZ37bmFJfPFP4uU1KhMzF3VtLvG3PKAtUOROcTjcXANpt8Oa31wBqdVLIt+/vxjcGJV58A3Y9RYtFiOkGvpnGS+9szvVpJcTAMwgCWo/FRUkZs3mlwQwcB2PxvVTmfxlUlYFp78YCY4gVqv6KTtxl9DXR8cLQY67jULmRlN5UxcqStK8l4c10N/w2LOT/pExnAVHE1d2bFB7auFYmQkQ0qXGpZzhGp9VKPObbzUoCaXdP4X7Gn9YG/Dtb42E6HtiFH6hN5H4A2sq5KpVFONSmFZ3xAH3k/4XUl/Z4yW5slObzj/zg/SS3Clfdyw+METLVzA0GeM3xIpmJn5b7nLsTE5y7Bo3fi3cF9PLU/w2qDwMSPw113fhSGC Swnmqkd/ eyP02IjcNgkneQYkEqmxINNc8aqbdyJ8O3+QVFPG7Vue/svjAHhsPGazcpjSN9xEhr+KaRZJjCZJovqKuwM+y3Gcnq5kjKV5MIUXksWtWv8KyqdtTgFT3+JUkOOHTop93xSHObHRtvtRr3uIKiQMF7aez+kfV397mQ3ck6gp37zEUdoHS1l3FqrJ9NJ+xwsElHGW12w/uiXGrvjqFa9dNuGMqTBJSX+6iEWT+D9Z32hXV2ITZ3BofH8PT7SZIpyFXVUq+me0HYDprVMb7aa8IhO2iTdJEUxirvwDJkKhYmiJaufbg1hW7berO84GO9K6fgrSXDvDKgXrlNJG7BTyrWDfJfcvn+Qd1fb9y61jLdNZiS+K0WkekWoIhLBPwZ5n3nmhiLbR7JiTtHqyhugZ23Ee712ppspGBxlUxLKW/CDMV2HA6QmEPxBAQIv5huxK+RfPUYKHssu36wBdUNkBfODhW1tsVC3M/9BetCJt0Ebg5hA0/82PgLPHjyYA/eqIt8MoaBwcMHmKu+Xw2quJmNFSqk0rFM5GpIprRdCW/QpIjQWof5FWhao6qAA== 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: The watermark check in compaction_zonelist_suitable(), called from should_compact_retry(), is sandwiched between two watermark checks already: before, there are freelist attempts as part of direct reclaim and direct compaction; after, there is a last-minute freelist attempt in __alloc_pages_may_oom(). The check in compaction_zonelist_suitable() isn't necessary. Kill it. Signed-off-by: Johannes Weiner Acked-by: Vlastimil Babka --- mm/compaction.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 83ecbc829c62..40ce4e6dd17e 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2291,13 +2291,6 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, for_each_zone_zonelist_nodemask(zone, z, ac->zonelist, ac->highest_zoneidx, ac->nodemask) { unsigned long available; - unsigned long watermark; - - /* Allocation can already succeed, nothing to do */ - watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK); - if (zone_watermark_ok(zone, order, watermark, - ac->highest_zoneidx, alloc_flags)) - continue; /* * Do not consider all the reclaimable memory because we do not