Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp941124rwr; Fri, 5 May 2023 07:08:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YMPDeM6zFRHa1b6TTlCbv3k38cS+D8UX8HWAxt4u2QvLbAwasI16e3wOGtSEUFDVLjfdT X-Received: by 2002:a17:903:110c:b0:1ab:1241:f671 with SMTP id n12-20020a170903110c00b001ab1241f671mr1554997plh.29.1683295719709; Fri, 05 May 2023 07:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683295719; cv=none; d=google.com; s=arc-20160816; b=vWrmr7b1/gGaFR+VdqKaaf1ki8+nKhso+oMbweCXyoasWj1UstIZ/1v8W1TmufYjGW vZpDW3Oxj0L34Slmug+tMsm8+xS0ijTwM2NuULzFPu0DI+Z1vrCBgj2/XAcjVaiXU6sC YOHSQV4KOCfffz1rHqnO6E7LMXw5HjuyKRvFQn54H+UFu+JYzo/w5pr12fkebPZCCN6J 8mId7eKC5CBw0K/46+UNCOf/zum7qPohFcr5uXjATuZlOjAEctBOU+sUhI/+4GkWk9W4 xhb/XuWiQ4VeP/mJ7HciLcwhK66b1Zn7c984AM4cEseelreMOb+9dsw0vtF5b0RnOcHO QNWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OAJHHR5cW5zZppYz7Dqy+tRpazmn4q+ZTLJfKmwg/AU=; b=W3eGPI783tf0VZRQNGV1AVhVAmgr3w02ULYATQs2GTLMzUQ6L+V7mT4EPGw7tU4RlR 2NjAjOfnc9fXDz9UwdyZCTfLQi1RQHMONDgoJ1jW/r0ZBsd61PJr9wd2SRbZMUpDu244 j4qG+Tc36i/nYrFH8jXO4ROSYJRTUlPsWZL+Oovkq+ExeIM+02GL7iCc5RDMA5cN6adW hkTDj/ldfD8EskWZ2+DsDxU/3Fg5QXcARCTKA30JvzUM+PKIjDXlRISvD92uwp0kR0C/ n3dmWDo0DOoBrIRlFy0BP8hARgTp26RhkM21SvXUGc4tvZc0sBQmJ5Z+qzVAFsnJCLXZ SA4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EJlEpl44; 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 ce21-20020a17090aff1500b00250366a3a83si663769pjb.188.2023.05.05.07.08.06; Fri, 05 May 2023 07:08:39 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EJlEpl44; 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 S232608AbjEENdj (ORCPT + 99 others); Fri, 5 May 2023 09:33:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231954AbjEENdh (ORCPT ); Fri, 5 May 2023 09:33:37 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26EDA20741; Fri, 5 May 2023 06:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=OAJHHR5cW5zZppYz7Dqy+tRpazmn4q+ZTLJfKmwg/AU=; b=EJlEpl44I8W/6AL75Uu7TvyziQ RVvBZ9mcyGdPikqbzI3SjFqg5Erc2zYDBz0PSdjioDTgcLE5tZlAF4if8QiQXIGGY4DLIqxI4Uc7L 1moJENTgO5pKKM0GfDA1EGDoWmiObGiaOSIrvFB8BIvekd+Cn050DkDEPfSBKBnDtcHMxHY8LjT7h JCDU0OHXbtfnVk5YS3FsSYCI5ZRAvixzDdeUiXugrxylRWQ4bSEGBbw4w+IIyVbmktVd1AbZtRG2n XzvfNsTB8W3jDJBGJbC9Gmpz7DHt1jdFYmds+DNQ+x79cOQISNlH7x/fkwEGJK7L90pzoLVOnbmzI 9fDWnPMw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1puvY5-00BVcU-FH; Fri, 05 May 2023 13:32:37 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id C7D943003CF; Fri, 5 May 2023 15:32:35 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 87FCF21353002; Fri, 5 May 2023 15:32:35 +0200 (CEST) Date: Fri, 5 May 2023 15:32:35 +0200 From: Peter Zijlstra To: Wander Lairson Costa Cc: 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 , Steven Rostedt , 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: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 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.