Received: by 10.192.165.148 with SMTP id m20csp541079imm; Fri, 20 Apr 2018 10:51:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+vou15T7aaqj2T7J2Pb56xkocVlaVXq0Ae23iosvG5LBM6GWEU91l2/ME60glnJJoDgJMx X-Received: by 2002:a17:902:a5c2:: with SMTP id t2-v6mr11172334plq.360.1524246717669; Fri, 20 Apr 2018 10:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524246717; cv=none; d=google.com; s=arc-20160816; b=SJST8N9CKkAqklbMQb6GASYxOI4QqYmHtnQGPA7gt3kJLR1ybAmBH2uutyFfF38KiV BfeefgXKEZGqSvo8coYiu7X3zHUM3DCVsHyqYqdX8x7uencoLZwDoi1e2CK7ZUw77N/u aSYbTfqq4QDRmhQkW7ifXe4DDwN4ceoysjgdWHix1pRy+5zIB2tUruEftRg3yXMHVHwp 3/mTjmSPtolCWDd8GEIpuUV+2iYOBQaAA0ywl3F8bFuP/O05MzMXavSdi1sDCLEFioOp MksA2GzhhHFa5zoFdWjkIWImDfbFViusCGEdX0NfNQCbqwIzvkhl5/xGG2ykRGK3CUc1 Qh8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=Q9gBsJTHMr1GmHCSHjDwdDwe53bxmPar8TDXM6Vnnlo=; b=qUu/J/aTgPIzuDaT497uBi3SR3kzwEnIgqocPNjedUFpCu/3JNLDS9yWjfIWgpjgPw ROXc3McFLbhR1smYkduF6JGngw8XHkBXc4lt8qo/Nl6iBegWG6mnmc3tJqx8fTzv40vf nMHuCcekoPsJIRZ9/XpU27fH2d7rv+ngg8KPsV2ofmtiiC86B4rvEaEpVtYzcB9KbgmV ptRBdh00pnUE2/EFIgAWvGrty5h91+6Cz5pmFvlYblhmkHC59v5d6ZV/uCDgoRTcx/lF UNpXxy07bmQ3lqxH9IhxsDNiRe4eup5OgMBspgf1nFS2nCL54Q+L7IomU42yHBPdbZXR GnaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1-v6si6080224plb.549.2018.04.20.10.51.42; Fri, 20 Apr 2018 10:51:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753520AbeDTRu3 (ORCPT + 99 others); Fri, 20 Apr 2018 13:50:29 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:52444 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753419AbeDTRu2 (ORCPT ); Fri, 20 Apr 2018 13:50:28 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D92ED1435; Fri, 20 Apr 2018 10:50:27 -0700 (PDT) Received: from armageddon.cambridge.arm.com (armageddon.cambridge.arm.com [10.1.206.84]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A3CFC3F587; Fri, 20 Apr 2018 10:50:26 -0700 (PDT) Date: Fri, 20 Apr 2018 18:50:24 +0100 From: Catalin Marinas To: Chunyu Hu Cc: mhocko@suse.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Dmitry Vyukov Subject: Re: [RFC] mm: kmemleak: replace __GFP_NOFAIL to GFP_NOWAIT in gfp_kmemleak_mask Message-ID: <20180420175023.3c4okuayrcul2bom@armageddon.cambridge.arm.com> References: <1524243513-29118-1-git-send-email-chuhu@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1524243513-29118-1-git-send-email-chuhu@redhat.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 21, 2018 at 12:58:33AM +0800, Chunyu Hu wrote: > __GFP_NORETRY and __GFP_NOFAIL are combined in gfp_kmemleak_mask now. > But it's a wrong combination. As __GFP_NOFAIL is blockable, but > __GFP_NORETY is not blockable, make it self-contradiction. > > __GFP_NOFAIL means 'The VM implementation _must_ retry infinitely'. But > it's not the real intention, as kmemleak allow alloc failure happen in > memory pressure, in that case kmemleak just disables itself. Good point. The __GFP_NOFAIL flag was added by commit d9570ee3bd1d ("kmemleak: allow to coexist with fault injection") to keep kmemleak usable under fault injection. > commit 9a67f6488eca ("mm: consolidate GFP_NOFAIL checks in the allocator > slowpath") documented that what user wants here should use GFP_NOWAIT, and > the WARN in __alloc_pages_slowpath caught this weird usage. > > > WARNING: CPU: 3 PID: 64 at mm/page_alloc.c:4261 __alloc_pages_slowpath+0x1cc3/0x2780 [...] > Replace the __GFP_NOFAIL with GFP_NOWAIT in gfp_kmemleak_mask, __GFP_NORETRY > and GFP_NOWAIT are in the gfp_kmemleak_mask. So kmemleak object allocaion > is no blockable and no reclaim, making kmemleak less disruptive to user > processes in pressure. It doesn't solve the fault injection problem for kmemleak (unless we change __should_failslab() somehow, not sure yet). An option would be to replace __GFP_NORETRY with __GFP_NOFAIL in kmemleak when fault injection is enabled. BTW, does the combination of NOWAIT and NORETRY make kmemleak allocations more likely to fail? Cc'ing Dmitry as well. > Signed-off-by: Chunyu Hu > CC: Michal Hocko > --- > mm/kmemleak.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/kmemleak.c b/mm/kmemleak.c > index 9a085d5..4ea07e4 100644 > --- a/mm/kmemleak.c > +++ b/mm/kmemleak.c > @@ -126,7 +126,7 @@ > /* GFP bitmask for kmemleak internal allocations */ > #define gfp_kmemleak_mask(gfp) (((gfp) & (GFP_KERNEL | GFP_ATOMIC)) | \ > __GFP_NORETRY | __GFP_NOMEMALLOC | \ > - __GFP_NOWARN | __GFP_NOFAIL) > + __GFP_NOWARN | GFP_NOWAIT) > > /* scanning area inside a memory block */ > struct kmemleak_scan_area { > -- > 1.8.3.1