Received: by 10.192.165.148 with SMTP id m20csp2485468imm; Sun, 22 Apr 2018 08:01:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+2B/Lpv8nmq79j+qmzM2pzXeOR93kvNx5uJYuJvOyaQl6ry8c2YrQnyos4Y8DZGQsIGXhw X-Received: by 2002:a17:902:8c91:: with SMTP id t17-v6mr17920175plo.182.1524409318149; Sun, 22 Apr 2018 08:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524409318; cv=none; d=google.com; s=arc-20160816; b=iYYPyYNDtCEmyyzSNuXe57kFt0Y6qPWrr2Ttsxep/nA8XcHa83eTAt0RtU/9ppwV2v BH2Hw8KMSz21W/vQk50ETzI5H6TPcIInwEQXV3AO2bcyPa06ImdFd2GMznlrZFaLH9sy 2jGn5clPqVgDQTIX0EzRdmMV9Yzv8VIvHNApORQ5y7eVbqiOj869HvW7JT8Mj7c0BktB i/vYs8/rv1bPPdfYEgKkrSwh2LBbBIrzo6HltZQLC2yl61UtYFXpNmhPZDSc1V7rd6qb VhyzIPFStwLdrHem1Os2JLnlipAeetyZSDilFJc11xMbs7TiTxY1Vm68c7ZcVOed0gyf WCwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=F+PonJL1FSqSWhwIngCWmV6Dizi7iwwCi6ZVOshdusI=; b=MA/cYrYs8b+7WDWvGzYkI2X1PiXmmQr5+lpCkLi2r+buk5GHud7CkIk+QIXe2/w9v1 QARXnK37BTRujXm9Pp0VOi6c3McrS+J7cb6qr5OdDJDwa+9CoH0YoDWkidSecrifltGw yhkaGgdyuSVGdFlb2Qu3H8rHM/kuFK1A/vIpdvnFxPsqguyzaxkCMyyfZMc2lPw/1xSt Zl5Brj2xC2ZpS3z8HQjLz56pSr4NxBSJKPDoTgh/KZNJWZTjQQK1UWiV60HVXTnTKmxz wkzr+NWHuHq3yvlsDEMBBB23AXHzPbclcLWtIlOxX413QlJw4N0AeSyvdgeAK9nZikp6 797w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=u9FJYc80; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4-v6si9569191plr.407.2018.04.22.08.01.43; Sun, 22 Apr 2018 08:01:58 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=u9FJYc80; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754305AbeDVPAp (ORCPT + 99 others); Sun, 22 Apr 2018 11:00:45 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:37684 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753830AbeDVPAj (ORCPT ); Sun, 22 Apr 2018 11:00:39 -0400 Received: by mail-pf0-f174.google.com with SMTP id p6so7163345pfn.4 for ; Sun, 22 Apr 2018 08:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=F+PonJL1FSqSWhwIngCWmV6Dizi7iwwCi6ZVOshdusI=; b=u9FJYc80xvkURRjmNUVX5sQzXH02YWocd/ctgyQBRGxDNg/x4dBUkC+tYD/UIyJIta jy2iftrsleWkLK9sA8Sz6f/pBBSRWLveg/dyUkuIoqBEothsVKgBsLk90vCNRZvt+FL8 2gFy92/s2Jk5nszPwH+a067iVl2Fw7YeYt3Kqog8gtGGr+PyiFqGGq7PilCy0HAIJoVz exM2H+CYylPqfxuhecXvgontlw+57lIGXX7Hd8WKthzIBBo4nDwea3oKn0ZDrFtURctu FNJ/4oZSiy5lMtaS10Idxr4vWvE6b5bqhEIcf+rZxAeh+TIw/LQEMf9i13jYU2SMW18e tx+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=F+PonJL1FSqSWhwIngCWmV6Dizi7iwwCi6ZVOshdusI=; b=cq3CaaJYvisel5s/ae4uKRYgDYilzaZ+QD2Pq4AzefBL6hfGArUOdPR1dK8PxY02l8 Nipqtm6eKQUpjJcR4Jt6Na1U37hMgb7Ar28r8y3Cht/mmdCUm08DQfDflkNZZuiKPHtA X/N4+ceQI1DW0KG9qa2kUHXvNKb7E+pyV5zQ4LPUry98IcxiuQ1gaa5wFq80ycbPqqIa vzcardal80+RyNxCdKGUfdxHvszt7odSLP9fLTzq3Z9QoOE11F6Z8cpZq9M2IulC9VBi lgaWELUSYsTl1RgMvoHfR1Ex+BcG1xwpwowJT6HHpuQoEA0j8/DlfmHyj5pYarx1GYV1 yPhw== X-Gm-Message-State: ALQs6tCkytsvyzFTFqA7VGG1H2xX+o+6MWbfz7Dh1ism2aDDVc4/hnz1 inG5wJ8Buxvq4g5Mf47+9vsTAxLLWDVPzrcqYb3+dA== X-Received: by 10.101.101.207 with SMTP id y15mr14042824pgv.84.1524409238590; Sun, 22 Apr 2018 08:00:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.147.130 with HTTP; Sun, 22 Apr 2018 08:00:18 -0700 (PDT) In-Reply-To: <20180422125141.GF17484@dhcp22.suse.cz> References: <1524243513-29118-1-git-send-email-chuhu@redhat.com> <20180420175023.3c4okuayrcul2bom@armageddon.cambridge.arm.com> <20180422125141.GF17484@dhcp22.suse.cz> From: Dmitry Vyukov Date: Sun, 22 Apr 2018 17:00:18 +0200 Message-ID: Subject: Re: [RFC] mm: kmemleak: replace __GFP_NOFAIL to GFP_NOWAIT in gfp_kmemleak_mask To: Michal Hocko Cc: Catalin Marinas , Chunyu Hu , LKML , Linux-MM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 22, 2018 at 2:51 PM, Michal Hocko wrote: > On Fri 20-04-18 18:50:24, Catalin Marinas wrote: >> 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. > > Cannot we simply have a disable_fault_injection knob around the > allocation rather than playing this dirty tricks with gfp flags which do > not make any sense? > >> BTW, does the combination of NOWAIT and NORETRY make kmemleak >> allocations more likely to fail? > > NOWAIT + NORETRY simply doesn't make much sesne. It is equivalent to > NOWAIT. Specifying a flag that says "don't do fault injection for this allocation" looks like a reasonable solution. Fewer lines of code and no need to switch on interrupts. __GFP_NOFAIL seems to mean more than that, so perhaps we need a separate flag that affects only fault injection and should be used only in debugging code (no-op without fault injection anyway).