Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3855890pxk; Tue, 29 Sep 2020 07:56:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6UC3tWHrKjmuTEWPpHN+BjvN5QmSZH5wbh+ioAH/GgT74F4kSC81fnvuGv6O9kOEMBLuk X-Received: by 2002:a17:906:f917:: with SMTP id lc23mr2029412ejb.233.1601391388294; Tue, 29 Sep 2020 07:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601391388; cv=none; d=google.com; s=arc-20160816; b=R+I627wTix8sJIKQvlxMUwAl1WXntXAowbG7Rh0tovFkjRVIbwe8jM2TDcH2iKaoS7 I2brbyUue6Z/w7u9wxOBf2XkAv05ddj5z5kZe4DoUVdenG4J/SczdS67LKXAPQ5DSvf+ ffcXyt459P0MR1SiTURlemL+GDxcinRbgqNRgdW5Mp9CN4XlyIU/c7dYa885iksnaBTb E7PqeTUOOXtPU0tuhsjCQs+mQnTic20sLKksW35FTZVlsaVXCMiUqmjz/YgC0IpB0YMc 5Y1Xp9ydtjj2VKe/VhQ2Qb1LjkAP0Kq9Jokc8z96ksQi8jbe+y2l2pHK9JepZgtnjk9c /B5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=IgDvWNQP8iyuHEvr4G441L71BKSYFJPWhAP8LkzWJfg=; b=hhJF2pmE63Vav9YbmXP+FxrmSAzqxxRz1LDcRYB//w+hnBCGcZwzNz3O+LGFJeGYuu OunZQ5+JO66ce+rlQ2xfe4LOQ0iyxU9SItjUiKSME9JoLMujrBHp1quaURKnegxctCQ0 nvjkR2DHVnMKqW0OuO8m+M2mcb+awKMjl4dRhqxqK369NQX+zcJTXA0i/1smGFOMMxHs oF+JzF881NtoUl+ujuR9vmvO1yTcz6CmiI/9YUPSwFIAdqh0NlJh2NuA7nQSmK3N+Z7K EaQ2+H0KPxVlXE/AYoeMiLEVigx7b/jK4hdzABTEI6RSvPQBJha4YroEsrbLMGHbVVS3 lpGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=eoKKMBN7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c17si2957580ejx.205.2020.09.29.07.56.04; Tue, 29 Sep 2020 07:56:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=eoKKMBN7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731500AbgI2OyJ (ORCPT + 99 others); Tue, 29 Sep 2020 10:54:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:33862 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728937AbgI2OyH (ORCPT ); Tue, 29 Sep 2020 10:54:07 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601391245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IgDvWNQP8iyuHEvr4G441L71BKSYFJPWhAP8LkzWJfg=; b=eoKKMBN7CEGS/O8wpnxX5YX5p7R/6oj0pmjByAZssa/tlgDzObwBIbhZXkZHaNf3yxFnjs /xxRgUM/x4iZ6RwvlYDvqSTGjNG6UgIhlOVv1JFsk77ppGGHvo3dx1IKn0uI5+hjhXkchS /V0QnFBKAlwY5qjuSlhyF3uziX8+a1k= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CB7CAAD0F; Tue, 29 Sep 2020 14:54:04 +0000 (UTC) Date: Tue, 29 Sep 2020 16:54:03 +0200 From: Michal Hocko To: Daniel Vetter Cc: "Paul E. McKenney" , Juri Lelli , Peter Zijlstra , Sebastian Andrzej Siewior , Lai Jiangshan , dri-devel , Ben Segall , Linux-MM , "open list:KERNEL SELFTEST FRAMEWORK" , linux-hexagon@vger.kernel.org, Will Deacon , Ingo Molnar , Anton Ivanov , linux-arch , Vincent Guittot , Herbert Xu , Brian Cain , Richard Weinberger , Russell King , Ard Biesheuvel , David Airlie , Ingo Molnar , Geert Uytterhoeven , Mel Gorman , intel-gfx , Matt Turner , Valentin Schneider , linux-xtensa@linux-xtensa.org, Shuah Khan , Jeff Dike , linux-um , Josh Triplett , Steven Rostedt , rcu@vger.kernel.org, linux-m68k , Ivan Kokshaysky , Rodrigo Vivi , Thomas Gleixner , Dietmar Eggemann , Linux ARM , Richard Henderson , Chris Zankel , Max Filippov , Daniel Bristot de Oliveira , LKML , alpha , Mathieu Desnoyers , Andrew Morton , Linus Torvalds Subject: Re: [patch 00/13] preempt: Make preempt count unconditional Message-ID: <20200929145403.GE2277@dhcp22.suse.cz> References: <87bli75t7v.fsf@nanos.tec.linutronix.de> <20200916152956.GV29330@paulmck-ThinkPad-P72> <20200916205840.GD29330@paulmck-ThinkPad-P72> <20200929081938.GC22035@dhcp22.suse.cz> <20200929090003.GG438822@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200929090003.GG438822@phenom.ffwll.local> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 29-09-20 11:00:03, Daniel Vetter wrote: > On Tue, Sep 29, 2020 at 10:19:38AM +0200, Michal Hocko wrote: > > On Wed 16-09-20 23:43:02, Daniel Vetter wrote: > > > I can > > > then figure out whether it's better to risk not spotting issues with > > > call_rcu vs slapping a memalloc_noio_save/restore around all these > > > critical section which force-degrades any allocation to GFP_ATOMIC at > > > > did you mean memalloc_noreclaim_* here? > > Yeah I picked the wrong one of that family of functions. > > > > most, but has the risk that we run into code that assumes "GFP_KERNEL > > > never fails for small stuff" and has a decidedly less tested fallback > > > path than rcu code. > > > > Even if the above then please note that memalloc_noreclaim_* or > > PF_MEMALLOC should be used with an extreme care. Essentially only for > > internal memory reclaimers. It grants access to _all_ the available > > memory so any abuse can be detrimental to the overall system operation. > > Allocation failure in this mode means that we are out of memory and any > > code relying on such an allocation has to carefuly consider failure. > > This is not a random allocation mode. > > Agreed, that's why I don't like having these kind of automagic critical > sections. It's a bit a shotgun approach. Paul said that the code would > handle failures, but the problem is that it applies everywhere. Ohh, in the ideal world we wouldn't need anything like that. But then the reality fires: * PF_MEMALLOC (resp memalloc_noreclaim_* for that matter) is primarily used to make sure that allocations from inside the memory reclaim - yeah that happens - will not recurse. * PF_MEMALLOC_NO{FS,IO} (resp memalloc_no{fs,io}*) are used to mark no fs/io reclaim recursion critical sections because controling that for each allocation inside fs transaction (or other sensitive) or IO contexts turned out to be unmaintainable and people simply fallen into using NOFS/NOIO unconditionally which is causing reclaim imbalance problems. * PF_MEMALLOC_NOCMA (resp memalloc_nocma*) is used for long term pinning when CMA pages cannot be pinned because that would break the CMA guarantees. Communicating this to all potential allocations during pinning is simply unfeasible. So you are absolutely right that these critical sections with side effects on all allocations are far from ideal from the API point of view but they are mostly mirroring a demand for functionality which is _practically_ impossible to achieve with our current code base. Not that we couldn't get back to drawing board and come up with a saner thing and rework the world... -- Michal Hocko SUSE Labs