From mboxrd@z Thu Jan 1 00:00:00 1970 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 90ED4C433EF for ; Fri, 11 Feb 2022 06:49:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24AF66B0078; Fri, 11 Feb 2022 01:49:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FB5E6B007B; Fri, 11 Feb 2022 01:49:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C2D56B007D; Fri, 11 Feb 2022 01:49:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id F26976B0078 for ; Fri, 11 Feb 2022 01:49:44 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id ADE6B181AC9C6 for ; Fri, 11 Feb 2022 06:49:44 +0000 (UTC) X-FDA: 79129573488.11.2758CF2 Received: from mail-oo1-f74.google.com (mail-oo1-f74.google.com [209.85.161.74]) by imf19.hostedemail.com (Postfix) with ESMTP id 432CF1A0006 for ; Fri, 11 Feb 2022 06:49:44 +0000 (UTC) Received: by mail-oo1-f74.google.com with SMTP id r12-20020a4aea8c000000b002fd5bc5d365so5073859ooh.18 for ; Thu, 10 Feb 2022 22:49:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Gp3MzKjywklApxzwU7bA0E+IdrMiraVuIp3bbtkpPwY=; b=pZFidtCwL5VMsnJRP/9b9wHwk02Whf8q/difXoIKsdZUTOmtfykRIOjUqweW4jqnAY 8AEQsIf7BJ3qv1w8Ny3VBvWoNOmFTRKN3MfOMCY09iJzuIfqwdWFh7mMh1dOoqJ4ANRG kk6Yyu5VN4IsdIxQHdbPDB8jrS384vnBeQ0zTXmINULyixuihlw86O9M7+bkOQkq5FCF Lrhhz8wMvYt8tbAjV4cuO7v+/OfmJKzHuP1Xt8E8P3AuoqUne3R/7i1gblDPs3CiLF4I Lu2aeoDUQLQNqiMdUjzemZ+fOLmEn6qSvVpIVsT10mL7z1OHdnOzDR/O/QikLdqga1Ns Ahuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Gp3MzKjywklApxzwU7bA0E+IdrMiraVuIp3bbtkpPwY=; b=41846UTQ8pxRC43mWVnBhOgV0/mtt50ebJ5eXyR76I/WIimej6zojaU+2WOg1RzFWB 7Q/xT1zzmxq2JD12ojnQ+IYGttIeetoQK3/NRJ9L00RmyWdkO7skZFT4+jNogOyLz/j/ gelTaPwr9buUEf6qXGzltPb8ZG8E8jPcUbS6QU1hG9okluSWlGSIjs1khvdzkYRqBRNV 0bu/vXoTGRWmATjnY2JLS50cry3A02HLeZMSHI7csArwmW/TX4t9MHCRMzFlpoT5mOzU COJ9ndCkb03TZC/5GmwOqrarsUJ4HUV3gOK+n4VNYEnwUolWx8kSn/x3WEociPdPGP1l 8ObQ== X-Gm-Message-State: AOAM53327/IhxJJnuqF7WXpUHmwCg+bj+YbdGiUj4h547AdNiD3qL15W TyZyn+sU8IXjskqYQ/Bwydwlqd8jHiL6Bg== X-Google-Smtp-Source: ABdhPJw3ASDB+yZZwSrQEVhj4dACHJ86v54Lv8O291KKTat+VzaAivyC/3ZBnBIy1wraZJwv+qm5+0amn6FRHw== X-Received: from shakeelb.svl.corp.google.com ([2620:15c:2cd:202:9a07:ef1a:2fee:57f1]) (user=shakeelb job=sendgmr) by 2002:a05:6808:1918:: with SMTP id bf24mr473270oib.253.1644562183473; Thu, 10 Feb 2022 22:49:43 -0800 (PST) Date: Thu, 10 Feb 2022 22:49:15 -0800 In-Reply-To: <20220211064917.2028469-1-shakeelb@google.com> Message-Id: <20220211064917.2028469-3-shakeelb@google.com> Mime-Version: 1.0 References: <20220211064917.2028469-1-shakeelb@google.com> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog Subject: [PATCH v2 2/4] memcg: unify force charging conditions From: Shakeel Butt To: Johannes Weiner , Michal Hocko , Roman Gushchin Cc: Chris Down , Andrew Morton , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Shakeel Butt Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 432CF1A0006 X-Stat-Signature: b3hit47obmyq3xt7e36mimhd4npq84r8 X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=pZFidtCw; spf=pass (imf19.hostedemail.com: domain of 3BwcGYggKCEQyngqkkrhmuumrk.iusrot03-ssq1giq.uxm@flex--shakeelb.bounces.google.com designates 209.85.161.74 as permitted sender) smtp.mailfrom=3BwcGYggKCEQyngqkkrhmuumrk.iusrot03-ssq1giq.uxm@flex--shakeelb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam06 X-HE-Tag: 1644562184-676178 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: Currently the kernel force charges the allocations which have __GFP_HIGH flag without triggering the memory reclaim. __GFP_HIGH indicates that the caller is high priority and since commit 869712fd3de5 ("mm: memcontrol: fix network errors from failing __GFP_ATOMIC charges") the kernel lets such allocations do force charging. Please note that __GFP_ATOMIC has been replaced by __GFP_HIGH. __GFP_HIGH does not tell if the caller can block or can trigger reclaim. There are separate checks to determine that. So, there is no need to skip reclaiming for __GFP_HIGH allocations. So, handle __GFP_HIGH together with __GFP_NOFAIL which also does force charging. Please note that this is a noop change as there are no __GFP_HIGH allocators in the kernel which also have __GFP_ACCOUNT (or SLAB_ACCOUNT) and does not allow reclaim for now. Signed-off-by: Shakeel Butt Reviewed-by: Roman Gushchin --- Changes since v1: - None mm/memcontrol.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index f12e489ba9b8..292b0b99a2c7 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2564,15 +2564,6 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask, goto retry; } - /* - * Memcg doesn't have a dedicated reserve for atomic - * allocations. But like the global atomic pool, we need to - * put the burden of reclaim on regular allocation requests - * and let these go through as privileged allocations. - */ - if (gfp_mask & __GFP_HIGH) - goto force; - /* * Prevent unbounded recursion when reclaim operations need to * allocate memory. This might exceed the limits temporarily, @@ -2646,7 +2637,13 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask, goto retry; } nomem: - if (!(gfp_mask & __GFP_NOFAIL)) + /* + * Memcg doesn't have a dedicated reserve for atomic + * allocations. But like the global atomic pool, we need to + * put the burden of reclaim on regular allocation requests + * and let these go through as privileged allocations. + */ + if (!(gfp_mask & (__GFP_NOFAIL | __GFP_HIGH))) return -ENOMEM; force: /* -- 2.35.1.265.g69c8d7142f-goog