Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1700573rwi; Wed, 19 Oct 2022 14:17:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM43Gt1VBrTO0dYsx7EjTZ3EI+GHP4GUFR5eDcTaiamUZIW3Sy4WKtPGoQer2hKiaSOGoXWq X-Received: by 2002:a05:6402:148a:b0:459:2eab:9b0a with SMTP id e10-20020a056402148a00b004592eab9b0amr9181329edv.139.1666214239706; Wed, 19 Oct 2022 14:17:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666214239; cv=none; d=google.com; s=arc-20160816; b=fO/8RkpJ2lvnjByrjW4o1ht//AYVcsur5ntldhSu3MpQGaLsuxio6d/k9ysk7Vu18S B1qCFTWjpWu7gH8KwUPzr9Rvf6rKql7/8SkuzYfVV/KpLbQ+8qLPO1+ObUIf+K9lvL2A /n0m/I+202hPKZDZkwbhiW9KtQEnaqUiIOT8/4ps4/vJI83qz/4yUDiNjnGJkCHA9f4Q C4apMclUB74Br5YoUgv0J3H3rVGzmrWeVAsRob/OM1+/AVj+SBUnZz++zgfUj5FCK4gd 0oDPZKPGKdcf2vbc9izLqfAeSsmijPJPFZ63DbSNwPEXr5ueaskUoQfanUCt8cfY/5lz isRg== 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=C5fVcK31viwo6cd+Ntr7JvcXlPspuKK/0tBhkAp7rS4=; b=wPH95dlCd+KJFLRa04oMMwGHjs2lCwLQVWaiddOEhi+O8O7yKS5KVxr2F21mIm5C3s 3C1GeFzOj0DkrJdJxS9/NtHe52Tz6vKXELeY631nl+P/vM42BtorwiF5NP+l+dzKfjZK aknhoFB6nDR4Mk2zTP44G72ZJ2zENDmlM/E/TxvS/CGIZNtEzUYepzZkijhMzOQrsMTp qh0CYdF4cX3LUsEQv7qCcjElJDr4ZSMGgRSg3X2ZsGBNIFAoyXDLvwCahrCnCc1dB+cp 0wNh9ywMaQ23dnZnNRywxKggZNd27tOacHMotjvk94gN8zQ38m5HD40Xew45gxm59H8t s1cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=bbSVGaHM; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s23-20020a508d17000000b0045a26e1b61csi13754425eds.305.2022.10.19.14.16.53; Wed, 19 Oct 2022 14:17:19 -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=@zx2c4.com header.s=20210105 header.b=bbSVGaHM; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbiJSUTi (ORCPT + 99 others); Wed, 19 Oct 2022 16:19:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231241AbiJSUTg (ORCPT ); Wed, 19 Oct 2022 16:19:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07980240AC for ; Wed, 19 Oct 2022 13:19:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B7461B822EB for ; Wed, 19 Oct 2022 20:19:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D90FDC433C1; Wed, 19 Oct 2022 20:19:30 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="bbSVGaHM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1666210768; 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: in-reply-to:in-reply-to:references:references; bh=C5fVcK31viwo6cd+Ntr7JvcXlPspuKK/0tBhkAp7rS4=; b=bbSVGaHMrn3+fdih8eHeNZKmyvNtAFlmp0SakMWD716TytdSbCA9Urv9G/y5v1txQdL8Vx DDizKMClOts+I3M0vy8BhMV5cw9xi8Gu64h5OPb69gI24IaPUm/ZM2A4PgnISpqFLwUcQ6 H3FQW7LibPmJT2A/wbQJ6d8YFLUzKFI= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id f73e1fa5 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 19 Oct 2022 20:19:27 +0000 (UTC) Date: Wed, 19 Oct 2022 14:19:23 -0600 From: "Jason A. Donenfeld" To: Tvrtko Ursulin Cc: "Intel-gfx@lists.freedesktop.org" , "Eric W. Biederman" , linux-kernel@vger.kernel.org, sultan@kerneltoast.com Subject: Re: [Intel-gfx] signal: break out of wait loops on kthread_stop() Message-ID: References: <0029af41-bf24-9972-10ac-f52e1bdcbf08@linux.intel.com> <41455798-1dcb-135f-516d-25ab9a8082f5@linux.intel.com> <8acc3e4a-abbc-32bc-626e-7a216f6755c3@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <8acc3e4a-abbc-32bc-626e-7a216f6755c3@linux.intel.com> X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS 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 Wed, Oct 19, 2022 at 09:09:28PM +0100, Tvrtko Ursulin wrote: > Hm why is kthread_stop() after kthread_run() abuse? I don't see it in > kerneldoc that it must not be used for stopping threads. Because you don't want it to stop. You want to wait until it's done. If you call stop right after run, it will even stop it before it even begins to run. That's why you wind up sprinkling your msleeps everywhere, indicating that clearly this is not meant to work that way. > Yep the yields and sleeps are horrible and will go. But they are also > not relevant for the topic at hand. Except they very much are. The reason you need these is because you're using kthread_stop() for something it's not meant to do. > Never mind, I was not looking for anything more than a suggestion on how > to maybe work around it in piece as someone is dealing with the affected > call sites. Sultan's kthread_work idea is probably the right direction. This would seem to have what you need. Jason