Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1529534iog; Sat, 25 Jun 2022 11:50:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tIu9X/JEfbMS13LnPfRtB5XGaYXJql6PCg0GLsr4hhz53X4mjD16m2SttSFYHgnIXBX1A1 X-Received: by 2002:a17:90a:eace:b0:1ec:b2a6:c9cf with SMTP id ev14-20020a17090aeace00b001ecb2a6c9cfmr10936366pjb.26.1656183046659; Sat, 25 Jun 2022 11:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656183046; cv=none; d=google.com; s=arc-20160816; b=MB4rvjd0p0HaQTjBkR8C8BiD6AjGOy3JhQHFmT42RSpcCzEfrwFEB/QMQ3Gw/seW+C ycHYjmukmDkEcZKWpaoywPnqc0HLR1BXbk1C1M/vcHWJcod8bnggulSIeV8fWaA5MMP/ N/n7PAgyzzWqNCHuBvChKoCMk4foQeLOlKHepXNwGfP0E166/fZ1j/123u4n+hjuDXW3 OY8LhtgaJ61TGwbsIQhPLDCNyKN04fRuaH2rK1lykviLijNvAxAh8B9tu0eqeQBSo6ro r5TeoLrCk6PCkD7EcDuyS+js8kTmLGRSOdVF5IHm2s7tCNc+PKmrK3TBamjcUwWkMgGB NfZQ== 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=q1sO1ws/MZKwL9KLkfXSuGi7R88qOwYnXVh1EIrjSrY=; b=QSBWoek6M91WoCBXE+G82UvekYJaufMsfipyIU1U7EwqvVLaFI5dEGmlNLNF7zZho3 RhbBmC27nAP/Zht1+6W3zNH9Hz7t5yLAyQm8eLtIpOq8v2YbvETN1rthjPCqRiNbmS98 nFu8t4JFshIqMugSu+5Kf9QiUtgaxJj3apa8Ogjb+GOYcjHTa/iqYmquN+d+1xvkR94g c+YZKklfvTtXCmyO+MKZciWHbdoL5Mjlq4X0tCJFzFemoZzdsAhoLLPDn7OZcObqmbz1 2CDLgFhULAEkJPqoQwwaJ5QXe2v4S8+1xMutbe+Q1g/moflXwt8P4bzbDGrIj1ihZOAN 7hDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=ISxJVME0; 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 145-20020a630697000000b003fdb97d8757si7659624pgg.378.2022.06.25.11.50.24; Sat, 25 Jun 2022 11:50:46 -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=ISxJVME0; 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 S233145AbiFYSZo (ORCPT + 99 others); Sat, 25 Jun 2022 14:25:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231311AbiFYSZn (ORCPT ); Sat, 25 Jun 2022 14:25:43 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 686B9D7C for ; Sat, 25 Jun 2022 11:25:41 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id u15so10928369ejc.10 for ; Sat, 25 Jun 2022 11:25:41 -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=q1sO1ws/MZKwL9KLkfXSuGi7R88qOwYnXVh1EIrjSrY=; b=ISxJVME02GrBsU5FOg/fWOKziOqTrxvLeknV+yVMk6+SoT6zIeSzfP6F+MJkKiLIRe l03OYyl8xShG0EmKvNGqPJ4TEmCNwz+nW8rzmX1UyG/EX0XIb4g6mW+SEog8A1sIEzwM ehqdlKfTBC8wDmJsD5tc4cuQ10YnDBaVbkLTI= 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=q1sO1ws/MZKwL9KLkfXSuGi7R88qOwYnXVh1EIrjSrY=; b=BYGu94kpQQAkmuKqCIDxu8XmFvmKoONV8dkmZJIA/x8yN5VUbl3763YW3eMc+BAcYn 1E+8LtWxGPFgMP7cTxvdoUkpwHdWJb2OO5kFyRQNdZpUaLPLxgqHNtdui7Sq/FbzZ+xn /EVzMlOF1qZqb6dW11675i0hpBW1tGJH+ttT71vTCI9Ugbih//KAZ97FIM+Vu1Qi5QXG pu8A6r7Ui1Nc4l6wrN68wY9sTV/88ETdK326huA3fRbyX8ZIqjC68tdj9KLntXhfI8uc C5eAEGEQBXDC9ZGWEvhNx0DZbSk7K3Z8eLB2BfpUXL8nQsBbe9zw2kQE2BudujGlIFjO l5hQ== X-Gm-Message-State: AJIora+BRX81xo2uXR70HuG/wG+LWpbVFG/nRDsyZprLhHo1jpAXpxCA VIz1q3mEtxBv/+7LQVeVXqKhJBkTdqEpO5hH X-Received: by 2002:a17:907:c06:b0:701:eb60:ded with SMTP id ga6-20020a1709070c0600b00701eb600dedmr5053218ejc.178.1656181539727; Sat, 25 Jun 2022 11:25:39 -0700 (PDT) Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com. [209.85.128.50]) by smtp.gmail.com with ESMTPSA id k25-20020a170906971900b00724e6a55d1asm2848180ejx.197.2022.06.25.11.25.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Jun 2022 11:25:38 -0700 (PDT) Received: by mail-wm1-f50.google.com with SMTP id h14-20020a1ccc0e000000b0039eff745c53so3230530wmb.5 for ; Sat, 25 Jun 2022 11:25:37 -0700 (PDT) X-Received: by 2002:a05:600c:354c:b0:39c:7e86:6ff5 with SMTP id i12-20020a05600c354c00b0039c7e866ff5mr10129558wmq.145.1656181537671; Sat, 25 Jun 2022 11:25:37 -0700 (PDT) MIME-Version: 1.0 References: <20220622140853.31383-1-pmladek@suse.com> <874k0863x8.fsf@email.froward.int.ebiederm.org> In-Reply-To: <874k0863x8.fsf@email.froward.int.ebiederm.org> From: Linus Torvalds Date: Sat, 25 Jun 2022 11:25:21 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: re. Spurious wakeup on a newly created kthread To: "Eric W. Biederman" Cc: 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 10:36 AM Eric W. Biederman wrote: > > Let me suggest someone create a new variant of kthread_create that takes > all of the parameters the workqueue code wants to set. I suspect the real issue is that that the kthread code simply shouldn't use the kernel_thread() helper at all. That helper is literally designed for "start a thread, run this thing". That's what it *does*. And that's not at all what the kthread code wants. It wants to set affinity masks, it wants to create a name for the thread, it wants to do all those other things. That code really wants to just do copy_process(). Or maybe it really should just use create_io_thread(), which has a much better interface, except it has that one oddity in that it sets the flag that does this: if (args->io_thread) { /* * Mark us an IO worker, and block any signal that isn't * fatal or STOP */ p->flags |= PF_IO_WORKER; siginitsetinv(&p->blocked, sigmask(SIGKILL)|sigmask(SIGSTOP)); } that then has special semantics. Now, those special semantics may actually be exactly what kthreads wants, but they are important: /* * PF_IO_WORKER threads will catch and exit on fatal signals * themselves. They have cleanup that must be performed, so * we cannot call do_exit() on their behalf. */ which is about that "what happens for fatal signals" thing. Linus