Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp986389rwr; Fri, 5 May 2023 07:40:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ57DhlyTMY9DYl5ZOz24EqvptN/UB1iKeMTsaVZdPj3Yz+Q6fSmOyceg6duFu4FpBhQuz9V X-Received: by 2002:a17:90b:4f4a:b0:24e:37a8:a19 with SMTP id pj10-20020a17090b4f4a00b0024e37a80a19mr1669348pjb.47.1683297655207; Fri, 05 May 2023 07:40:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683297655; cv=none; d=google.com; s=arc-20160816; b=zv4tyB+3lZtPJg/ylSAxb7pIZ5YYk2P84eS9KCdagCtyKsS77xZG6Cbtv+smBVjPjE /yMQDtbskhogswCpx/C8TnXmP79fjQP3Qs9LrePzfQcSJIe/pTYfoI4wk/G/svoAe8RA d9yxEPFjYYdIN7pWg8JQ6z2zrlJMcKA6fAz0l+6MAn3PiIEfZvI/+ZajJ9ejoeYTvi/M N5Gyh028E5UMETLhU7guIYk3ojpyrZ0TvB2W7yPqMttSY693B8yf3EKgGmUVmYTRmJng 72TbS/lLdgMCEyeMHxF05uyK/iYjh4Txv497BSZhs2AzsOtsYu/ndAKO4JJeLKZXtAkk uAsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=77/K5xUGZgAe2K+4EuCG4UD6RDBUzpMFkz2rGuVASQ0=; b=DdovgZ6WZv4rgJoqmxR0oQlgMjeK3Bms0yAfKYq8rHUO9mZqT5suV0Rc5fjYdz3M3r DYVbZr3Az0uSHFRKv59FvwPUv7o/y2XTcdMjafV9eH9SspAyYvsJDgCd2dEunCok7cZw y+a3c9pmFuKJG2sFs+RnWr4sSOTwOeRnAtFr7pkN31aSpOrmHZH7vHE1m6N6mcS4zc+z rmLL7Z6BbeI90mbawr5hg0fhfzGBXvxtSr3+MeJY/KsRYUEkBbotUnsmMkr7eLIqEnBR W7EFh018/1SwavAsqIFRt9xPctEeqpuXW8XYeYWX+zfkJI0xtfxPyKST2r0x1tpmts96 4LrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hk15-20020a17090b224f00b0025026c97f40si2085545pjb.145.2023.05.05.07.40.42; Fri, 05 May 2023 07:40:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232578AbjEEO0O (ORCPT + 99 others); Fri, 5 May 2023 10:26:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232308AbjEEO0M (ORCPT ); Fri, 5 May 2023 10:26:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8059612EAB; Fri, 5 May 2023 07:26:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0DFE263E6E; Fri, 5 May 2023 14:26:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDEA5C433D2; Fri, 5 May 2023 14:26:06 +0000 (UTC) Date: Fri, 5 May 2023 10:26:02 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: Wander Lairson Costa , Oleg Nesterov , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Will Deacon , Waiman Long , Boqun Feng , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , "Eric W. Biederman" , Brian Cain , Kefeng Wang , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Christian Brauner , Andrei Vagin , Shakeel Butt , open list , "open list:PERFORMANCE EVENTS SUBSYSTEM" , Hu Chunyu , Paul McKenney , Thomas Gleixner Subject: Re: [PATCH v7 2/3] sched/task: Add the put_task_struct_atomic_safe() function Message-ID: <20230505102602.2052c83a@gandalf.local.home> In-Reply-To: <20230505133235.GG4253@hirez.programming.kicks-ass.net> References: <20230425114307.36889-1-wander@redhat.com> <20230425114307.36889-3-wander@redhat.com> <20230504084229.GI1734100@hirez.programming.kicks-ass.net> <20230504122945.GA28757@redhat.com> <20230504143303.GA1744142@hirez.programming.kicks-ass.net> <20230504152424.GG1744258@hirez.programming.kicks-ass.net> <20230505133235.GG4253@hirez.programming.kicks-ass.net> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 5 May 2023 15:32:35 +0200 Peter Zijlstra wrote: > On Thu, May 04, 2023 at 03:21:11PM -0300, Wander Lairson Costa wrote: > > On Thu, May 04, 2023 at 05:24:24PM +0200, Peter Zijlstra wrote: > > > On Thu, May 04, 2023 at 11:55:15AM -0300, Wander Lairson Costa wrote: > > > > > > > > Then I'm thinking something trivial like so: > > > > > > > > > > static inline void put_task_struct(struct task_struct *t) > > > > > { > > > > > if (!refcount_dec_and_test(&t->usage)) > > > > > return; > > > > > > > > > > if (IS_ENABLED(CONFIG_PREEMPT_RT) && !preemptible()) > > > > > call_rcu(&t->rcu, __put_task_struct_rcu); > > > > > > > > > > __put_task_struct(t); > > > > > } > > > > > > > > > > > > > That's what v5 [1] does. What would be the path in this case? Should I > > > > resend it as v8? > > > > > > It's almost what v5 does. v5 also has a !in_task() thing. v5 also > > > violates codingstyle :-) > > > > IIRC, the in_task() is there because preemptible() doesn't check if it > > is running in interrupt context. > > #define preemptible() (preempt_count() == 0 && !irqs_disabled()) > > When in interrupt context preempt_count() will have a non-zero value in > HARDIRQ_MASK and IRQs must be disabled, so preemptible() evaluates to > (false && false), last time I checked that ends up being false. Interesting, I can't find v5 anywhere in my mail folders (but I have v4 and v6!). Anyway, from just the context of this email, and seeing IS_ENABLED(CONFIG_PREEMPT_RT), I'm guessing that in_task() returns false if it's running in a interrupt thread, where preemtible() does not. -- Steve