Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4274933rwr; Mon, 8 May 2023 05:40:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ59z65FCzuH45SnjehUeuzPHI3XNmQ3frghdCXHwY+g0CbVO6l3+x2pbeS877nB9qGo8H9P X-Received: by 2002:a05:6a20:12d2:b0:ee:3ddf:9737 with SMTP id v18-20020a056a2012d200b000ee3ddf9737mr11373318pzg.28.1683549653910; Mon, 08 May 2023 05:40:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683549653; cv=none; d=google.com; s=arc-20160816; b=SXp2z82x3PuMVP+lJSSGRHasZV58waATBRkXfSo4d3454Gh29ic19pbJ8L7k0itugT VreNYXaPI75rXLy3RY7Ni5q4GxynQTUzm4ercZHh+lZTXclVgNxSL0CiSA4YbJZ3X4FM EqXbQ01yizr9wSdYpL6LhzG/t+09O/Oxt0KSGh9nch0cmLJn/xCTUdN9JJmu/L2jgYtK TmVjDTLFZAq7zxka7SCfu9uy4yOMFny5XYbqwYmkPvCOJhyYgnxrenNyYeMb7j54SM1r pC7hATAM3KfrJZo2IxDm+neokKpLYntR48PrlHLmOJnSbOXyUVggs9T+TcK2L3QuOWEp MUSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=lgrzGxAxmI/spviOHV2b8UBBldlWDCIioMic8trwoYg=; b=lXvkzpzZtMuRSROttuQzUUbwjClKaMC9jrGGi1ibFc6MXZnoj+/paU5q3mqfHvWuGq 5G8YyYGAK5x0wyw620uPsEp21yHuPnxZ1TACizZWzRvA13DQY6KsGAxGf5ipfzly0W0z 6Ha7eBUE2Vut4l2ZtkP8Xf3gtCxi45gZo4AAveIwdvU3sPCHyKG82vKMky7d51Vno0mI pA4RlK+F04G7mWlBKDEgrAVzPKJTs4GKP9TByJxv6cvfEYFT+Ko0i17b54XXU8BZK/Ow Whq69yS4V2ULGhJe9G5mwOBauqNo4bXdUX95xlgT925ydEpHE0gGUkQ8Ntn8LpFjAh1X obFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Bw8+57xo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a63aa09000000b005196bc25628si8438555pgf.579.2023.05.08.05.40.41; Mon, 08 May 2023 05:40:53 -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=@redhat.com header.s=mimecast20190719 header.b=Bw8+57xo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234076AbjEHMaB (ORCPT + 99 others); Mon, 8 May 2023 08:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234678AbjEHM3v (ORCPT ); Mon, 8 May 2023 08:29:51 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1383E3C3D1 for ; Mon, 8 May 2023 05:28:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683548910; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lgrzGxAxmI/spviOHV2b8UBBldlWDCIioMic8trwoYg=; b=Bw8+57xoqvf0lgYZQLr/DQ2Rw3DUDO2q0+A546LDsHoAd7rEhypYHaFyi1C+NyEeSVpWEv 2Bz7SlHWc//je2PC33bnEckBWpGI8pZBLRkqIWzOrub6mNyxY5OCPBLiORoEGrCCjgd/NI jy5eMPC6uU+i+kbcGNSrbRfylbMF2R0= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-127-uzmTTyjHN9KczZXNMIfa3Q-1; Mon, 08 May 2023 08:28:29 -0400 X-MC-Unique: uzmTTyjHN9KczZXNMIfa3Q-1 Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-643fdfb437aso8936217b3a.0 for ; Mon, 08 May 2023 05:28:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683548908; x=1686140908; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lgrzGxAxmI/spviOHV2b8UBBldlWDCIioMic8trwoYg=; b=d9TIr1EGlnSNaw7zh/HY2GmskTuSQXgmr0huytEadkqxCHLi5jkyieYIvG6LMaxWNz pVVHayjm3LWrGYrVSzWeRcxWI11CJM3WLo1tgoNYmaVsY2825wNJYQgBDrxddNxmo8Gm XOpyC+wdeY9C+9ucgSFhq9czGE+LPUxzYjl9puTQ9e2jFfF526MVwqzvHEWn+Zuv+wDL v+Lb6m5KIFqX9qMJze0ZHLGtdf3T7lhd8x7lFjyC+45GO33QZmOEyKTCKnAosT7wI5Rv uvmVmCVvzATWJj1b0jrDkfcro7o0xH/yJsUetq7QQVx1tKfhPPNR40ku3ajp+HZyw8aG DyWQ== X-Gm-Message-State: AC+VfDwp3McbAQJC5DejI4dHgzFjf05KbTAw/PGZJOTtMhB90ljEwfFu HgH0LMvTbplImeoHApQDSYKQ3BssS3lKWa9EzHA4yc0E6v6o6mAOrKuIv641FZ3zVqGJI8nyPHG cYimmSUNcWNJeAfgoW95SKjDzwWNtF19E1HPcQFzV X-Received: by 2002:a17:902:c943:b0:1a9:2a9e:30a8 with SMTP id i3-20020a170902c94300b001a92a9e30a8mr19852467pla.9.1683548907999; Mon, 08 May 2023 05:28:27 -0700 (PDT) X-Received: by 2002:a17:902:c943:b0:1a9:2a9e:30a8 with SMTP id i3-20020a170902c94300b001a92a9e30a8mr19852446pla.9.1683548907634; Mon, 08 May 2023 05:28:27 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <20230505133235.GG4253@hirez.programming.kicks-ass.net> From: Wander Lairson Costa Date: Mon, 8 May 2023 09:28:16 -0300 Message-ID: Subject: Re: [PATCH v7 2/3] sched/task: Add the put_task_struct_atomic_safe() function To: Peter Zijlstra 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 Fri, May 5, 2023 at 10:33=E2=80=AFAM 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? Shoul= d 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() =3D=3D 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. > When I first tested, I started with in_irq(), then I saw some warnings and added preemptible(). Never tested with preemptible() alone. Thanks, I will change that and test = it.