From patchwork Tue Mar 31 13:16:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 11467799 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 27E061392 for ; Tue, 31 Mar 2020 13:16:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DFC9020772 for ; Tue, 31 Mar 2020 13:16:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="w9G5xdSJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFC9020772 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1034F6B0032; Tue, 31 Mar 2020 09:16:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0B2776B0037; Tue, 31 Mar 2020 09:16:39 -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 F09956B006C; Tue, 31 Mar 2020 09:16:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0200.hostedemail.com [216.40.44.200]) by kanga.kvack.org (Postfix) with ESMTP id DA58D6B0032 for ; Tue, 31 Mar 2020 09:16:38 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5DC8F4DBC for ; Tue, 31 Mar 2020 13:16:38 +0000 (UTC) X-FDA: 76655706876.17.comb41_57053e03dd240 X-Spam-Summary: 2,0,0,69c81a2f32ee83e2,d41d8cd98f00b204,joel@joelfernandes.org,,RULES_HIT:41:355:379:421:541:800:960:965:966:967:968:973:988:989:1260:1311:1314:1345:1431:1437:1515:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2525:2559:2563:2682:2685:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4385:4390:4395:5007:6119:6261:6653:6742:7903:9025:10004:11026:11232:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:12986:13069:13311:13357:13845:13846:13894:14096:14181:14384:14394:14721:21080:21433:21444:21451:21627:21789:21795:21796:21811:21939:21990:30012:30036:30051:30054,0,RBL:209.85.219.66:@joelfernandes.org:.lbl8.mailshell.net-66.201.201.201 62.14.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:25,LUA_SUMMARY:none X-HE-Tag: comb41_57053e03dd240 X-Filterd-Recvd-Size: 4895 Received: from mail-qv1-f66.google.com (mail-qv1-f66.google.com [209.85.219.66]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Tue, 31 Mar 2020 13:16:37 +0000 (UTC) Received: by mail-qv1-f66.google.com with SMTP id n1so10794781qvz.4 for ; Tue, 31 Mar 2020 06:16:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lWOY1a83oyzd8Wyzxobl7iyPgPSxUcv8H4rfgpi9Go0=; b=w9G5xdSJi2pwxLkw+UUYa9uD0cxKepK7FyN8BvxBNr7Qf28I7LNKazNm+grZ85uOZ3 YUp0H2DrxVoI8h+nOVinbooeJqV2zQ511twVls7fYGH+dwXNRxXxr3T3VCoRZ5/DGzhD eyZwCzRDkNzu/rI9nxQFLCQ6LvJiGX5snuiD0= 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:mime-version :content-transfer-encoding; bh=lWOY1a83oyzd8Wyzxobl7iyPgPSxUcv8H4rfgpi9Go0=; b=Tm+jNI6ndgNwmQ7N0iuGJWER5zO983la5FDamkz7RdEctMxQUNEBHiwthFDBj4FxXE 4dnKYpiDH4oDqSa1Tah5F6Ww3KTqhHEtyWG5BjhvpdXMcTpz/aaNhYIX5CdvAIMits// u7hltE4HyNTKKCmJKRUWpFsQgA8y9ru/J1cJlimsRNXda8MFZro6/X7sEzBaM9/H6FSQ eVipLRHjaA+VfdGIpgnYncnaOpnzKBp16XlIG/YslO9gfE/A1VonLHlhUrOMSeG4BYl/ f4Hn28wSRoi1VaForMmhsVXYgx1RYy7zYnQBuQRaNqTZN1LFdqe4OQN/Q6DhPU7Q6BNG y00Q== X-Gm-Message-State: ANhLgQ1Gm6JWeF/S9Yl2Jcru2trJJwhwOidNmUO5l72jZXh2Oym3DAVU EZGqI6intggnvaNlzZhmOyDVNg== X-Google-Smtp-Source: ADFU+vtXVj0qnZ925oHCMNMkIOnLjNT9wF24VWwCVSa51Qddhb1QgyuPqNP67rntZT+wlEmt8BzhpQ== X-Received: by 2002:a0c:f7d0:: with SMTP id f16mr16609830qvo.206.1585660597163; Tue, 31 Mar 2020 06:16:37 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id l16sm13731476qtc.73.2020.03.31.06.16.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 06:16:36 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , linux-mm@kvack.org, rcu@vger.kernel.org, willy@infradead.org, peterz@infradead.org, neilb@suse.com, vbabka@suse.cz, mgorman@suse.de, Andrew Morton , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , "Paul E. McKenney" , Steven Rostedt Subject: [PATCH RFC] rcu/tree: Use GFP_MEMALLOC for alloc memory to free memory pattern Date: Tue, 31 Mar 2020 09:16:28 -0400 Message-Id: <20200331131628.153118-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog 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: In kfree_rcu() headless implementation (where the caller need not pass an rcu_head, but rather directly pass a pointer to an object), we have a fall-back where we allocate a rcu_head wrapper for the caller (not the common case). This brings the pattern of needing to allocate some memory to free some memory. Currently we use GFP_ATOMIC flag to try harder for this allocation, however the GFP_MEMALLOC flag is more tailored to this pattern. We need to try harder not only during atomic context, but also during non-atomic context anyway. So use the GFP_MEMALLOC flag instead. Also remove the __GFP_NOWARN flag simply because although we do have a synchronize_rcu() fallback for absolutely worst case, we still would like to not enter that path and atleast trigger a warning to the user. Cc: linux-mm@kvack.org Cc: rcu@vger.kernel.org Cc: willy@infradead.org Cc: peterz@infradead.org Cc: neilb@suse.com Cc: vbabka@suse.cz Cc: mgorman@suse.de Cc: Andrew Morton Signed-off-by: Joel Fernandes (Google) Signed-off-by: Michal Hocko Acked-by: Paul E. McKenney Acked-by: Paul E. McKenney Signed-off-by: Michal Hocko --- This patch is based on the (not yet upstream) code in: git://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git (branch rcu/kfree) It is a follow-up to the posted series: https://lore.kernel.org/lkml/20200330023248.164994-1-joel@joelfernandes.org/ kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 4be763355c9fb..965deefffdd58 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -3149,7 +3149,7 @@ static inline struct rcu_head *attach_rcu_head_to_object(void *obj) if (!ptr) ptr = kmalloc(sizeof(unsigned long *) + - sizeof(struct rcu_head), GFP_ATOMIC | __GFP_NOWARN); + sizeof(struct rcu_head), GFP_MEMALLOC); if (!ptr) return NULL;