Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2480882rwd; Mon, 15 May 2023 12:17:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4XBfTicefvwcY/a+bENK5OZphvYPYGKPe5pubp9CQ2VR66GILKygOYJrwVSEcNqJgwY+ae X-Received: by 2002:a05:6a20:432a:b0:100:5a09:4524 with SMTP id h42-20020a056a20432a00b001005a094524mr32406677pzk.31.1684178255587; Mon, 15 May 2023 12:17:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684178255; cv=none; d=google.com; s=arc-20160816; b=ofUy/FW/OroYwH77ft9lwu/CF20p+mOgwPB84eEnZOaVIYzgzrttHaEnQnYnUCv+sH dxK8/DchFQc546vcG/88lvNkv2U2tGR9mwPJePUGAPj/ZcSWcSYnQfyHEm4W/tKv7aMo YC7n9C1eVkwHsBA0X0guFFChJqGpWIM8ODkEdFpe8atPWAKba40xXq6CgLZIH/GyM5eN YnlCzfXuPdu+QEn0sLXxKTjyAmICSJASv3t+hrrbXWRHckDf4REFydm+l0LJtkgRV/H6 UbhVPoofkHqEezQAFTvHjPo11hWGA13ELGhEnS/TFo68cMgDUYoKRfcbW4SW60CMPaZc lUyQ== 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=X+3CYqiGDk2yYqbtHSwUDrT4kehB36yZJGZI0UXY9BY=; b=c2rU3gr/2MWWmKEKpoWes5F0txp0Kvtbsqm2jXZOdQkL7ILWhTWJWXa0Vymp8gX6vu ei2xdLZSDzfUBkZUismhGjo/sDo+xQll2pS1W8anpxa9tzZRmp02U5VyntoNgWpa4qSf 0LZSIzrg1Ugr9c4jIlCJyKulSic+Hqh9wa3HsNDACdgK/n5/QJonHuWRzxnqA27hfigl XLCNMiI5CyRwImrXfgAi3lEJ1z71zAWS27r3DU8uLWHDLtWS8rVnBUplzPnjAIiGC1KZ cG4esjZ/fK98ja7plwCcusZIx/iWl1w4RchbShwjAd7JNwH7E/gg7laboX3mLvWHZAqj fUVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XZOjzJra; 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 h132-20020a636c8a000000b00528d057c33asi15582252pgc.854.2023.05.15.12.17.20; Mon, 15 May 2023 12:17:35 -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=XZOjzJra; 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 S243395AbjEOS7K (ORCPT + 99 others); Mon, 15 May 2023 14:59:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243644AbjEOS7J (ORCPT ); Mon, 15 May 2023 14:59:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE98A176CD for ; Mon, 15 May 2023 11:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684177103; 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=X+3CYqiGDk2yYqbtHSwUDrT4kehB36yZJGZI0UXY9BY=; b=XZOjzJra7TZESherpAMThuowPA3tN7vztQoJ2sLsdFQXII/Edt7bfbJXmO6BpMDdQ02ChL yLpEapB8OlzG0SFGt+VCuAAXlfGr1qL+9LgZpYy0PFRxpKXKia/ugMP2kdzvynaOE8UHk6 AtUQqsSWCWoll/SQRsMB3t4tWBJOlEQ= Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-132-cVW3bHNwN3uzu_yhCZb2Ag-1; Mon, 15 May 2023 14:58:21 -0400 X-MC-Unique: cVW3bHNwN3uzu_yhCZb2Ag-1 Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-1aae803a5eeso78949455ad.0 for ; Mon, 15 May 2023 11:58:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684177101; x=1686769101; 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=X+3CYqiGDk2yYqbtHSwUDrT4kehB36yZJGZI0UXY9BY=; b=PNTzaT99mk4HsLSwc79050YuhHhkyhW4A4mPpVjf2AZlTahx7gHbHj9WLDlsvOXm+Z fwejtxWC1nDqnIn+HDjLfV9I5P+XOMKunDhstmYev5EWaHY0ttWtEY+47kOHLNZE+VDp 1mLXCf6XcRn1i3Tu7Zgtj2nAdP47+XB5Bbbwyuh4/TecMxnZsRLsOY2mKY8GcgzSYzPL aX3/UpCddziv+k2ioptwEQiqVRFgBY4u+0dwqRboO+YVFuQNA6Mi5dWT1i30f3qLG2c0 gejzHOfEJyMsXatLoOxnXljApdaPMqHVuvrAqc8L8nUlx2fz96xReDq/SyfV74qb9gbT ad/g== X-Gm-Message-State: AC+VfDw97DRs/p17TDGNiHWpibBnsyXlQNlWth2lPhwLIoFDPQo4cRKe 7Obm0vfAkI7DOe78NmblOVwHZJL9Wnn5NpRiJUX+UICQe7MFymsyW/PdIJgi38E60L27izERvR4 Q+qRaU75YiSIprkNbGYNm+tKfieZBk9v3rdr+/uzi X-Received: by 2002:a17:902:a503:b0:1ae:197f:dba9 with SMTP id s3-20020a170902a50300b001ae197fdba9mr5168184plq.2.1684177100871; Mon, 15 May 2023 11:58:20 -0700 (PDT) X-Received: by 2002:a17:902:a503:b0:1ae:197f:dba9 with SMTP id s3-20020a170902a50300b001ae197fdba9mr5168157plq.2.1684177100631; Mon, 15 May 2023 11:58:20 -0700 (PDT) MIME-Version: 1.0 References: <20230515162249.709839-1-wander@redhat.com> <20230515164311.GC10759@redhat.com> <20230515180851.GD10759@redhat.com> In-Reply-To: <20230515180851.GD10759@redhat.com> From: Wander Lairson Costa Date: Mon, 15 May 2023 15:58:09 -0300 Message-ID: Subject: Re: [PATCH v8] kernel/fork: beware of __put_task_struct calling context To: Oleg Nesterov Cc: "Christian Brauner (Microsoft)" , "Michael S. Tsirkin" , Mike Christie , Peter Zijlstra , Guo Ren , Kefeng Wang , Andrew Morton , "Liam R. Howlett" , Suren Baghdasaryan , Mathieu Desnoyers , Nicholas Piggin , Andrei Vagin , open list , Hu Chunyu , Valentin Schneider , Sebastian Andrzej Siewior , Paul McKenney , Steven Rostedt 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, RCVD_IN_MSPIKE_H2,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 Mon, May 15, 2023 at 3:09=E2=80=AFPM Oleg Nesterov wro= te: > > On 05/15, Wander Lairson Costa wrote: > > On Mon, May 15, 2023 at 1:43=E2=80=AFPM Oleg Nesterov = wrote: > > > > > > Certainly I have missed something... > > > > > > but, > > > > > > On 05/15, Wander Lairson Costa wrote: > > > > > > > > -extern void __put_task_struct(struct task_struct *t); > > > > +extern void ___put_task_struct(struct task_struct *t); > > > > +extern void __put_task_struct_rcu_cb(struct rcu_head *rhp); > > > > > > I don't understand these renames, why can't you simply put this fix > > > into put_task_struct() ? > > > > > > > No particular reason, it was just a matter of style and keep the parts = simple. > > Well, to me a single/simple change in put_task_struct() makes more > sense, but I won't argue. > My initial thought was to break the code in smaller functions, but maybe just changing put_task_struct() could be better. > static inline void put_task_struct(struct task_struct *t) > { > if (!refcount_dec_and_test(...)) > return; > > if (IS_ENABLED(PREEMPT_RT) && ...) > return call_rcu(...); > > ... > __put_task_struct(); > ... > } > > > > > +static inline void __put_task_struct(struct task_struct *tsk) > > > > +{ > > > ... > > > > + if (IS_ENABLED(CONFIG_PREEMPT_RT) && !preemptible()) > > > > + call_rcu(&tsk->rcu, __put_task_struct_rcu_cb); > > > > + else > > > > + ___put_task_struct(tsk); > > > > +} > > > > > > did you see the emails from Peter? In particular, this one: > > > > > > https://lore.kernel.org/lkml/20230505133902.GC38236@hirez.pro= gramming.kicks-ass.net/ > > > > > > > I didn't notice the lock_acquire/lock_release part. However, I tested > > the patch with CONFIG_PROVE_RAW_LOCK_NESTING and there was no warning. > > Hmm. I tend to trust the Sebastian's analysis in > > https://lore.kernel.org/all/Y+zFNrCjBn53%2F+Q2@linutronix.de/ > > I'll try to look at it later, although I hope Sebastian or Peter > can explain this before I try ;) > The inability to see and reproduce the potential issue is part of my confusion about addressing this property. > Oleg. >