From patchwork Fri Apr 3 08:35:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 11472111 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CAA1315AB for ; Fri, 3 Apr 2020 08:36:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A145D20787 for ; Fri, 3 Apr 2020 08:36:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A145D20787 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A3DDA8E0009; Fri, 3 Apr 2020 04:36:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A14D48E0007; Fri, 3 Apr 2020 04:36:00 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DC978E0009; Fri, 3 Apr 2020 04:36:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id 766308E0007 for ; Fri, 3 Apr 2020 04:36:00 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3621B52DA for ; Fri, 3 Apr 2020 08:36:00 +0000 (UTC) X-FDA: 76665886080.28.show20_8bae2a6ec7641 X-Spam-Summary: 2,0,0,560f48b2c4f83164,d41d8cd98f00b204,mstsxfx@gmail.com,,RULES_HIT:41:355:379:541:800:960:966:967:973:988:989:1260:1263:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2525:2559:2563:2682:2685:2693:2859:2901:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4385:5007:6261:7576:8599:9025:10004:10128:11026:11257:11658:11914:12043:12297:12517:12519:12555:12679:12783:12895:12986:13069:13153:13228:13311:13357:13869:13894:14096:14181:14384:14394:14721:14849:21080:21444:21451:21627:30005:30054,0,RBL:209.85.128.65:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: show20_8bae2a6ec7641 X-Filterd-Recvd-Size: 3802 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Fri, 3 Apr 2020 08:35:59 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id i19so6771519wmb.0 for ; Fri, 03 Apr 2020 01:35:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GtpPxyoRisktwYV8GKqImVHBqT8VlKdeN8AOG5tsI4w=; b=Hqvgb9EjR0dGiblSsJpyPoWEWBprlN+Jv34npTrOMVwT6MWSUowdeBYSJSYHEKdIKs QW9Td7XSaHeznRAEGLFHSKRz8DtiJSQiprNf7TANCmvfFD6jgz+mX4W7VQfcg8rC20nb S7mttUijWExMkVwAd+eoZv87etSuAcacStUfAkcoEWxBXnb/KSPM3eYfVYxzvNJaL0u9 F/Nqo/ERRo2OvYsB5ofBqmoxmJkRO2IyY+fciUhRjXMzJT/KT1ATCcpgmPjvjN56PwJK O754rVyWuJfJSMNh8cX1MjlN8yLPxxFK/jiBcZte/8lbABSKpng5l+0o3Ws8emKbqb6P eZnw== X-Gm-Message-State: AGi0Pua6r5QjR87psz7sGpBSCOD6ausySzBRw6+w0EXquTmC/Dw/qoVQ Lt1rIxgK0e8JK/dtsOPdcwk= X-Google-Smtp-Source: APiQypKXYZXqpkSNfmPVOPnqf50MiBJus1LGu50LqojrBPE6PAqj6Q97YN1fijOnLAcDh2veZDOdAQ== X-Received: by 2002:a7b:c18c:: with SMTP id y12mr4615614wmi.56.1585902958758; Fri, 03 Apr 2020 01:35:58 -0700 (PDT) Received: from tiehlicka.suse.cz (ip-37-188-180-223.eurotel.cz. [37.188.180.223]) by smtp.gmail.com with ESMTPSA id v7sm11010275wrs.96.2020.04.03.01.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 01:35:58 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: Joel Fernandes , "Paul E. McKenney" , Neil Brown , , LKML , Michal Hocko Subject: [PATCH 1/2] mm: clarify __GFP_MEMALLOC usage Date: Fri, 3 Apr 2020 10:35:42 +0200 Message-Id: <20200403083543.11552-2-mhocko@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200403083543.11552-1-mhocko@kernel.org> References: <20200403083543.11552-1-mhocko@kernel.org> MIME-Version: 1.0 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: From: Michal Hocko It seems that the existing documentation is not explicit about the expected usage and potential risks enough. While it is calls out that users have to free memory when using this flag it is not really apparent that users have to careful to not deplete memory reserves and that they should implement some sort of throttling wrt. freeing process. This is partly based on Neil's explanation [1]. [1] http://lkml.kernel.org/r/877dz0yxoa.fsf@notabene.neil.brown.name Signed-off-by: Michal Hocko Signed-off-by: Michal Hocko Signed-off-by: Michal Hocko Signed-off-by: Andrew Morton --- include/linux/gfp.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index e5b817cb86e7..e3ab1c0d9140 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -110,6 +110,9 @@ struct vm_area_struct; * the caller guarantees the allocation will allow more memory to be freed * very shortly e.g. process exiting or swapping. Users either should * be the MM or co-ordinating closely with the VM (e.g. swap over NFS). + * Users of this flag have to be extremely careful to not deplete the reserve + * completely and implement a throttling mechanism which controls the consumption + * of the reserve based on the amount of freed memory. * * %__GFP_NOMEMALLOC is used to explicitly forbid access to emergency reserves. * This takes precedence over the %__GFP_MEMALLOC flag if both are set. From patchwork Fri Apr 3 08:35:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 11472113 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C79A15AB for ; Fri, 3 Apr 2020 08:36:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 42C832073B for ; Fri, 3 Apr 2020 08:36:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42C832073B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 079318E000A; Fri, 3 Apr 2020 04:36:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 029E98E0007; Fri, 3 Apr 2020 04:36:01 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5A978E000A; Fri, 3 Apr 2020 04:36:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id C92978E0007 for ; Fri, 3 Apr 2020 04:36:01 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8378C2465 for ; Fri, 3 Apr 2020 08:36:01 +0000 (UTC) X-FDA: 76665886122.05.fog80_8be08956ed851 X-Spam-Summary: 2,0,0,7f8c3017a1e91bad,d41d8cd98f00b204,mstsxfx@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3872:3874:4250:4321:5007:6119:6120:6261:7576:7901:7903:8957:10004:11026:11473:11658:11914:12296:12297:12438:12517:12519:12555:12679:12895:13069:13255:13311:13357:13894:14181:14384:14394:14721:21080:21444:21451:21627:30054,0,RBL:209.85.221.68:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: fog80_8be08956ed851 X-Filterd-Recvd-Size: 3493 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Fri, 3 Apr 2020 08:36:01 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id c7so7460558wrx.5 for ; Fri, 03 Apr 2020 01:36:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YmqsIpFQyQQ2Lq3jQLn2ED6h63YdDDqWuKLktL963FE=; b=ahGoLMbmnPu6118bZdCqCVXY2i65pN4sGpqFUkViDO2WwJyWr8I8fU3PMrZNnu5+Dw gZbqlVlGR/9PvipMLFGdH/xXdv5gIelOgKHpoXId/5Z6vOQPBD+Po2r4CdDpOTRwApue S9FKt7eXkclzf6wpkPmaB6scWy7lETjNfkTrYyHEqJTbnAlcp2OjpxEmJkKwKD6VNY0t 2R4FbPOlP0W9iFLNERupoMbrl82hVsFU3dJuh2E+vSY/M5HorQgClv0uEtFcJC01qkhY iBipf84UBu0ykvAtW18Tubr/Y6T0p9raPiGgw0u2XAW1AfuBW9za52RHb1PDOU2nvSfo 4jjA== X-Gm-Message-State: AGi0Pubtq4QBt15fcLo+laQ7pi9hv61aMAPQ6JM2W25JpgERdjkin5f7 nF1eqdYty99GVp7732tg3tE= X-Google-Smtp-Source: APiQypIG8pcQaw6IRSWQM+d3AwV+GjfW87kcXS+FPtd04pS58lgtBWpzeJsDAmRETTcbde+50hc16A== X-Received: by 2002:a05:6000:11c6:: with SMTP id i6mr8126218wrx.115.1585902959941; Fri, 03 Apr 2020 01:35:59 -0700 (PDT) Received: from tiehlicka.suse.cz (ip-37-188-180-223.eurotel.cz. [37.188.180.223]) by smtp.gmail.com with ESMTPSA id v7sm11010275wrs.96.2020.04.03.01.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 01:35:59 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: Joel Fernandes , "Paul E. McKenney" , Neil Brown , , LKML , Michal Hocko , "Paul E . McKenney" Subject: [PATCH 2/2] mm: make it clear that gfp reclaim modifiers are valid only for sleepable allocations Date: Fri, 3 Apr 2020 10:35:43 +0200 Message-Id: <20200403083543.11552-3-mhocko@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200403083543.11552-1-mhocko@kernel.org> References: <20200403083543.11552-1-mhocko@kernel.org> MIME-Version: 1.0 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: From: Michal Hocko While it might be really clear to MM developers that gfp reclaim modifiers are applicable only to sleepable allocations (those with __GFP_DIRECT_RECLAIM) it seems that actual users of the API are not always sure. Make it explicit that they are not applicable for GFP_NOWAIT or GFP_ATOMIC allocations which are the most commonly used non-sleepable allocation masks. Acked-by: Paul E. McKenney Signed-off-by: Michal Hocko Acked-by: David Rientjes Reviewed-by: Joel Fernandes (Google) --- include/linux/gfp.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index e3ab1c0d9140..8040fa944cd8 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -127,6 +127,8 @@ struct vm_area_struct; * * Reclaim modifiers * ~~~~~~~~~~~~~~~~~ + * Please note that all the following flags are only applicable to sleepable + * allocations (e.g. %GFP_NOWAIT and %GFP_ATOMIC will ignore them). * * %__GFP_IO can start physical IO. *