Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp163043pxk; Wed, 16 Sep 2020 00:40:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOg442244yqq/nvC/iXCgetCrUWm7AAZIM094D5eyN7yotDZN5nf3VGGrkPc/qNRS08CE/ X-Received: by 2002:a17:906:a251:: with SMTP id bi17mr23531490ejb.526.1600242034002; Wed, 16 Sep 2020 00:40:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600242033; cv=none; d=google.com; s=arc-20160816; b=L0xRCpmmiWzOpagX7X7xGJzofd8QSc/LT63KGomk/mjKufjx4Rn6ew4OE+1BkdHjKH Ml+1xEPAvgz38HRipt8Nyr5Ks7jPGuMylFwl2HbBjblLsOliC7R9SAlabCsZnFAcEr4N dzEJjOwuEzllNBnDDMnoANuozKiGGDHdPONy+fqDC5l+Gn3WK4usbDOcm9A9Imk6ha68 +dl1fsFJDRcLtAS9KLfGWCvvPCjOHcQGpp3nkmcioL7HWSG8JY+xvOS5PkJngRCg1LKs Zq7KL9erTb7coaeTglNpY5Pb4dwYqTP75VIMJs5cc0vik2s2CfXYxN6XCSW68XghAwlb QA9Q== 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 :in-reply-to:references:mime-version:dkim-signature; bh=ir83kA7yZmatKHQpy7nyYwdfudWOyhH141WksSrpLpI=; b=eyYDaz8D38SNBL1HEv+I76NqSEDx24TIXWy1IbeyRNJkacB7D/NlhXTlfjLGj/nTLc spi5J6LKtYeVrQhHttu63C7nLRstDckII83w8Pbi/h+y+5JvbSbm59ACNzDucejvPJhf Gx+WAQMAlSk7hU7YxLNiVY2XOCS3rD38Kx39P2Tf1SvHWCYFE34Ce9FoC7uN8ZGRRy6w zNU8sgUByaOD08r1WxNjsKyE+HDPC74f8udBnwA5z4yWeqyv6O4LddleYqesx/aUA52A ypRk+9EDejs8YhuetGo6gowqzvoeB+D7+tn108a10O3zvLooPw3nToASzit0riVytSIU lT4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=Wbmy2wm4; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u18si10936779ejf.75.2020.09.16.00.40.11; Wed, 16 Sep 2020 00:40:33 -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=@ffwll.ch header.s=google header.b=Wbmy2wm4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726518AbgIPHhh (ORCPT + 99 others); Wed, 16 Sep 2020 03:37:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726384AbgIPHhc (ORCPT ); Wed, 16 Sep 2020 03:37:32 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4B00C061797 for ; Wed, 16 Sep 2020 00:37:31 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id g10so5776590otq.9 for ; Wed, 16 Sep 2020 00:37:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ir83kA7yZmatKHQpy7nyYwdfudWOyhH141WksSrpLpI=; b=Wbmy2wm4Y3Z7IHj2WQgnSxJHvWaqiIYxvJrRLzN5yosJdstiBZVZo9gvc44pSE/nA1 P9hDpmjXczq2zLOkqvx/WHir/QasP1J2aBD5X+7FKjnP91s5nxsyqJv2jhU8PZzNRGRF pjrrhaFUmLe21mq1kggp9iTxwlhfZdVWViCcQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ir83kA7yZmatKHQpy7nyYwdfudWOyhH141WksSrpLpI=; b=YIJFUp4jc8jnv6DFcI+gT2Sgyjf0ntFNLGVfPsCuoDI8yJPdwFwh2UKQJbKs82ec3y k5yrYJ/5hWTwoByY9HuzIGKmdX8E6put7xoeaBta/FtJ42DMim1fGdJLvQhRoGJ4othH 110urJ+lYgTkLp/mcuMDIkcLokiQ1V2Z41IAaGM3F7x/7DSEw/TT7EWvBXIh0l1LsWfz o+RSFr9qiGbzaH13B59/YUPVSF96bhShBHH2CqT+BCxRuFLYyaVa1MrvOrcEiCpUc6N0 zdha0PQRPolc7ozGUgidEJVzVlK6lhiqvhZHP3chXSURAmemh/usS9KCy0PbR8bAO2nz OWjQ== X-Gm-Message-State: AOAM530yxQ+rMQqPve+72lu6/J0/PNPz3jr2qz63MKsLSRdBPZLlOmt+ FDWf9EcfNKnM+xrtfrWIY6GTdJEY+N/+O2oPJIi2tA== X-Received: by 2002:a05:6830:14d9:: with SMTP id t25mr16390529otq.188.1600241849077; Wed, 16 Sep 2020 00:37:29 -0700 (PDT) MIME-Version: 1.0 References: <20200914204209.256266093@linutronix.de> <871rj4owfn.fsf@nanos.tec.linutronix.de> <87bli75t7v.fsf@nanos.tec.linutronix.de> In-Reply-To: From: Daniel Vetter Date: Wed, 16 Sep 2020 09:37:17 +0200 Message-ID: Subject: Re: [patch 00/13] preempt: Make preempt count unconditional To: Linus Torvalds Cc: Thomas Gleixner , Ard Biesheuvel , Herbert Xu , LKML , linux-arch , Sebastian Andrzej Siewior , Valentin Schneider , Richard Henderson , Ivan Kokshaysky , Matt Turner , alpha , Jeff Dike , Richard Weinberger , Anton Ivanov , linux-um , Brian Cain , linux-hexagon@vger.kernel.org, Geert Uytterhoeven , linux-m68k , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Will Deacon , Andrew Morton , Linux-MM , Ingo Molnar , Russell King , Linux ARM , Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , intel-gfx , dri-devel , "Paul E. McKenney" , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan , Shuah Khan , rcu@vger.kernel.org, "open list:KERNEL SELFTEST FRAMEWORK" 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 Tue, Sep 15, 2020 at 7:35 PM Linus Torvalds wrote: > > On Tue, Sep 15, 2020 at 1:39 AM Thomas Gleixner wrote: > > > > OTOH, having a working 'preemptible()' or maybe better named > > 'can_schedule()' check makes tons of sense to make decisions about > > allocation modes or other things. > > No. I think that those kinds of decisions about actual behavior are > always simply fundamentally wrong. > > Note that this is very different from having warnings about invalid > use. THAT is correct. It may not warn in all configurations, but that > doesn't matter: what matters is that it warns in common enough > configurations that developers will catch it. > > So having a warning in "might_sleep()" that doesn't always trigger, > because you have a limited configuration that can't even detect the > situation, that's fine and dandy and intentional. > > But having code like > > if (can_schedule()) > .. do something different .. > > is fundamentally complete and utter garbage. > > It's one thing if you test for "am I in hardware interrupt context". > Those tests aren't great either, but at least they make sense. > > But a driver - or some library routine - making a difference based on > some nebulous "can I schedule" is fundamentally and basically WRONG. > > If some code changes behavior, it needs to be explicit to the *caller* > of that code. > > So this is why GFP_ATOMIC is fine, but "if (!can_schedule()) > do_something_atomic()" is pure shite. > > And I am not IN THE LEAST interested in trying to help people doing > pure shite. We need to fix them. Like the crypto code is getting > fixed. Just figured I'll throw my +1 in from reading too many (gpu) drivers. Code that tries to cleverly adjust its behaviour depending upon the context it's running in is harder to understand and blows up in more interesting ways. We still have drm_can_sleep() and it's mostly just used for debug code, and I've largely ended up just deleting everything that used it because when you're driver is blowing up the last thing you want is to realize your debug code and output can't be relied upon. Or worse, that the only Oops you have is the one in the debug code, because the real one scrolled away - the original idea behind drm_can_sleep was to make all the modeset code work automagically both in normal ioctl/kworker context and in the panic handlers or kgdb callbacks. Wishful thinking at best. Also at least for me that extends to everything, e.g. I much prefer explicit spin_lock and spin_lock_irq vs magic spin_lock_irqsave for locks shared with interrupt handlers, since the former two gives me clear information from which contexts such function can be called. Other end is the memalloc_no*_save/restore functions, where I recently made a real big fool of myself because I didn't realize how much that impacts everything that's run within - suddenly "GFP_KERNEL for small stuff never fails" is wrong everywhere. It's all great for debugging and sanity checks (and we run with all that stuff enabled in our CI), but really semantic changes depending upon magic context checks freak my out :-) -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch