Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp276951pxb; Wed, 24 Feb 2021 01:39:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDJgYiTG76tJYwiQ9pU97kQv26S8kFEwNNmas3bQifXAITxKSHF6fPX1g3K3CGyAoJl83H X-Received: by 2002:a05:6402:c0a:: with SMTP id co10mr23198539edb.351.1614159557808; Wed, 24 Feb 2021 01:39:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614159557; cv=none; d=google.com; s=arc-20160816; b=Siwa4T6QJMaIqplVCI47rSvajaa8eIwdlo/0ntUJFjBKkQtKcRw0RM8fMbZPHH6Ey2 APq2S++iXOaBtUiGMk940pJL3WO8vkcYcxVjmLH9GEZQ2GRClmHSMc5kt7+K+8wo+70l DPNlH0TKO8FMya95GbJ3S69vIV/E/9P/53DKCu3PKj059k1csLJ00GxiJXgX8YfUqLVd FASyMp7ZC/TkoS09StsK2kwZOHbyh1GTDyMsnHnu30vTtZp7zoy86x9bVXgplJXE48t4 UMp4wXH3fNUy6JLVwh08qArGiVYdnt+hWZVX4wUpfH7zlmVgzfOG6xD0yp6Xn/pM3ZcU Tj0A== 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=IB369nwp5DwxTBQfx+mYNcS//1xC7eRg/MH+Z8hl/hQ=; b=vqWhVvlM5YzGIx3qIgR25Uk8PnGSHRv7rlHJsfShL8wqdwdtCwgDfyi1MNveyoweHh 1lmzMHdvzlyi4YHCzzlUkI1AvbB6KNbOWbPSkuN+o8inyjOczBmnSUAzSdlr8ho2/hBP LEMtVC/uLStnZfGvwNZ699pEGTIKdh1ZETPJpbLMTDq1930OxXQgHAx5MYLEeyHq0Mm2 vUw2mzET7cgyT1zbB0ZsIlr42yZ3wFkxuXa/XZQdo2F515SS4rtlSXbHTGZP+xXXVGEJ 89JQGjBxV1SFw6t8Mr1FZnoGrbhQj3Fm9zVWNBUX9NZi/yK4RgZHej3CSGWi14nglFVU 0AfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=K0OkMI9H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si908785ejr.124.2021.02.24.01.38.53; Wed, 24 Feb 2021 01:39:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=K0OkMI9H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234662AbhBXJgA (ORCPT + 99 others); Wed, 24 Feb 2021 04:36:00 -0500 Received: from mx2.suse.de ([195.135.220.15]:58530 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234454AbhBXJfO (ORCPT ); Wed, 24 Feb 2021 04:35:14 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1614159266; h=from:from:reply-to: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=IB369nwp5DwxTBQfx+mYNcS//1xC7eRg/MH+Z8hl/hQ=; b=K0OkMI9Hs2bizmiP2geYKw2ebpXJ7PJakNHPDRdm98hwLB/ynySIDr5dEwzZTje2An5paw +YIabbxjb5gqwC6of57yf2ADasBNCaBjwlNWnhKPRU8rIMY1N+WZ4uictp5DACgKC0yTM7 D4OVDB6/XjGjkI+OlvJCgvUP2k0rmiQ= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4ECB4AE05; Wed, 24 Feb 2021 09:34:26 +0000 (UTC) Date: Wed, 24 Feb 2021 10:34:25 +0100 From: Petr Mladek To: Yiwei Zhang Cc: Christoph Hellwig , Andrew Morton , Felix Kuehling , Jens Axboe , "J. Bruce Fields" , Peter Zijlstra , Frederic Weisbecker , Marcelo Tosatti , Ilias Stamatis , Rob Clark , Mathieu Desnoyers , Liang Chen , Linux Kernel Mailing List , kernel-team Subject: Re: [PATCH] kthread: add kthread_mod_pending_delayed_work api Message-ID: References: <20210214000611.2169820-1-zzyiwei@android.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2021-02-23 14:29:37, Yiwei Zhang wrote: > > > which is not cool because it will make the > > > asynchronous effort a no-op. Is there a way we can include caller > > > thread metadata(task_struct pointer?) when it enqueues the work so > > > that the RT worker thread won't preempt the caller thread when that > > > queued work gets scheduled? Probably require the CPU scheduler to poke > > > at the next work...or any other ideas will be very appreciated, > > > thanks! > > > > This sounds like a very strange use case. > > Why is the worker kthread RT when the work can be delayed? > > > > If the kthread has to be RT because of another work then > > your proposal will not work. The delayed processing of > > low priority work might block and delay any pending > > high priority work. > > > > You should consider handling the less important work in a separate > > kthread worker with a lower priority or by the system workqueue. > > Just want to clarify that it's not about delayed_work any more. In my > latest question, it's a RT thread with normal work queued and > scheduled to be run immediately. However, I simply don't want the > worker to preempt the thread that queues the work. > > It's a high prio work that we don't want other random tasks to preempt > it. Meanwhile, we don't want it to preempt the called thread. In > addition, assume we can't raise the priority of those caller > threads(otherwise I'd be fine with using a workqueue). Honestly, it sounds weird to me. Either the caller or the worker has higher priority. Well, I think that behavior could be achieved by CONFIG_PREEMPT_NONE or CONFIG_PREEMPT_VOLUNTARY. Anyway, this is rather a question for scheduler experts. It is possible that it has some solution. But it is also possible that it is so specific behavior and it would complicate the scheduler too much. Best Regards, Petr