Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1702634iog; Sat, 25 Jun 2022 17:24:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v4IKzpqVcInSRYylqS6KjbMxM3a6panl4DmeN1qu5By90vjB8XwLKWlSD4qPsYWwlXv01U X-Received: by 2002:a17:907:7283:b0:722:e541:f157 with SMTP id dt3-20020a170907728300b00722e541f157mr5946140ejc.269.1656203067936; Sat, 25 Jun 2022 17:24:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656203067; cv=none; d=google.com; s=arc-20160816; b=osyas+HFba25adSyaC9ky/aVZT1EyFPvOm1qpZjqMHMjEkJWzO6UPQxiwfrDYlLOwO 86uUp3f25nOqvjbl00AZQjrw39Ho81TRa+b35Dyb3KckdWml4+xvqTHRuKUHm4XvPlaw WTBNN6VWO5l8p3BsYBNYdgziyuxmzBoauWzkLUrW/ehuxcU4VViywX7iqI2InkRZm5LN hhpYwa5xnHsRJ/WSsHbkLSR8VmVtKaf/NJ0Tz0Ouq9w08h6TbU77xCGXDDWU+QeJMa6L a9goZ4z44dHawPtW29Vv8qWWHwM6o5s/YFxxREmsEvHnEOjaJ/GyBMNYK7bPuLd9pSzv bkmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=fhLEFEWSQRbam1YvxY7yQ4RPKHD6h3bly2df1kg2Kh4=; b=tNtDVk6YHVskHSAB1h7gpNKl7/wTm4awXi0IQBMACZDvzBj1i/Kjaq6RLtC1hTzeQx JCsM7hvfBuFY/IOJHRGVcPEpw2ieG/BPamdZPwGH0o3CknwnKM5ykQK2VoFbg8POFN0P z94e0VR++/OjaoNCX3pypEgU50SQCfAZdtC225NzkYdIq974gU4VjcVJW8MuZDF5uVAJ sLXdRnZmwo50j7RzPfgTfCYA/M5UmR7xCQlcxy/wHWakTCFe0mjquj4ExEVHjFobIWoT 78nMn6GTnBQiEv39rAYYf0I+lagdZT3OeoMVtKrcHpBTfftlcZMPD/OgAvv4o4wKYG8W YkHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="bKom/uo/"; 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 l25-20020a1709062a9900b0071216b08163si5204463eje.264.2022.06.25.17.24.03; Sat, 25 Jun 2022 17:24:27 -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=@linux-foundation.org header.s=google header.b="bKom/uo/"; 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 S233544AbiFYXoB (ORCPT + 99 others); Sat, 25 Jun 2022 19:44:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233285AbiFYXn7 (ORCPT ); Sat, 25 Jun 2022 19:43:59 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FEB6BE03 for ; Sat, 25 Jun 2022 16:43:58 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id u15so11755775ejc.10 for ; Sat, 25 Jun 2022 16:43:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fhLEFEWSQRbam1YvxY7yQ4RPKHD6h3bly2df1kg2Kh4=; b=bKom/uo/JqKHAxEbU7+RneFpawB7xt8b5cFXzfj/CCY8owEqYeQ/ZQeb4RXfJUag6E U0/OdE0J4FVP0q28SNowikYNo4Jp6fSRgWDSO7Q3aww2e2GPvXjks8Zf4mp7z2kOw1pJ PqqO2ZJ8PW2qM+Ubf2QCOtsmsVmqDiefwouW4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fhLEFEWSQRbam1YvxY7yQ4RPKHD6h3bly2df1kg2Kh4=; b=pEUFrIY6JGCSiH7eBBI9HsLI24LYAr9RDduTaQD5MI3k7m3J98Xrls0zaPG81O60Bf Ur60TWiRxTz9gkzp2GbCeuNo84kQiptvHJyy4Ra7pzDYkaSM6tQ01GOHyQUOz3QX84z7 fJ13DztXbuCp1tzYQSTjDz23vu65qA2qx3hEv1Bfi3KdDq2FrJM5LmLPIxxS10YPPV2j tA1C6DAE7dzn0xu26ZqU4vaC6r+Z5/wz5P5JsMSI6SyVU88cu/ZTzGaM1TubHpM7wLjT h1nuBN9jlAp01TieOPKIdJVfm+LZyRf2kDqZXUBqPKTHak7qRd/8/fXFh00zBYeUF9rW RpGw== X-Gm-Message-State: AJIora/rBWWmXXbIbAcZdGNHHSmmsWGKDLTf3JYeDvYT0JvO39tOEWle WiSGFzIs+hab2OEnD3bDKGgeFy2VWAaSMAcH X-Received: by 2002:a17:907:6d0a:b0:722:b0b5:be69 with SMTP id sa10-20020a1709076d0a00b00722b0b5be69mr6112303ejc.76.1656200636886; Sat, 25 Jun 2022 16:43:56 -0700 (PDT) Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com. [209.85.221.43]) by smtp.gmail.com with ESMTPSA id m14-20020a1709061ece00b007121361d54asm3135739ejj.25.2022.06.25.16.43.55 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Jun 2022 16:43:55 -0700 (PDT) Received: by mail-wr1-f43.google.com with SMTP id w17so7943419wrg.7 for ; Sat, 25 Jun 2022 16:43:55 -0700 (PDT) X-Received: by 2002:a05:6000:1f8d:b0:21b:aaec:ebae with SMTP id bw13-20020a0560001f8d00b0021baaecebaemr5931643wrb.274.1656200635134; Sat, 25 Jun 2022 16:43:55 -0700 (PDT) MIME-Version: 1.0 References: <20220622140853.31383-1-pmladek@suse.com> <874k0863x8.fsf@email.froward.int.ebiederm.org> <87pmiw1fy6.fsf@email.froward.int.ebiederm.org> In-Reply-To: <87pmiw1fy6.fsf@email.froward.int.ebiederm.org> From: Linus Torvalds Date: Sat, 25 Jun 2022 16:43:39 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: re. Spurious wakeup on a newly created kthread To: "Eric W. Biederman" Cc: Christian Brauner , Tejun Heo , Petr Mladek , Lai Jiangshan , Michal Hocko , Linux Kernel Mailing List , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Andrew Morton , Oleg Nesterov Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Sat, Jun 25, 2022 at 4:28 PM Eric W. Biederman wrote: > > I presume you mean kthreadd games? Yeah, sorry. > So with the introduction of kthreadd the kernel threads were moved > out of the userspace process tree, and userspace stopped being able to > influence the kernel threads. Ahh. So essentially it's indeed just basically the parenting issue. > I want to say that all that is required is that copy_process copies > from kthreadd. Unfortunately that means that it needs to be kthreadd > doing the work, as copy_process does always copies from current. It > would take quite a bit of work to untangle that mess. Hmm. Yeah, it would probably be painful to replace 'current' with something else, due to locking etc. Using "current" has some fundamental advantages wrt using another thread pointer that may or may not be active at the same time. That said, there *is* another thread that has very similar "we don't need locking, because it's always around and it doesn't change": init_task. I wonder if we could basically get rid of every use of 'current' in kernel/fork.c with just a task pointer that is passed in, and then for kernel threads pass in 'init_task'. I'd hate to duplicate copy_process() entirely, when we probably could just consider it just a parenting issue, and say that you can have either 'current' or 'init_task' as the parent. And that 'init_task' would basically be the 'clean slate for kthreads'. Christian, comments? Linus