Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp754213pxb; Thu, 25 Feb 2021 14:24:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyl6wK5gksplWkMvDxZieYU+4NfYaawW4n7NmpC658fehVxffxTT9Q+W3vrlcZ6yqV2Ex0K X-Received: by 2002:a17:907:2513:: with SMTP id y19mr4911634ejl.241.1614291858848; Thu, 25 Feb 2021 14:24:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614291858; cv=none; d=google.com; s=arc-20160816; b=zJRExDg2nEntcty1iqqSpeXyWhlVIlbjGr2W2TinA21NzVustKfrAjkcu/5TjzVw+p bdn1PZcvfEqFCNQSSqcVLho5EUp1AXqo/FmLmY0Xd6NkqIvLQV2qi9dZF9xEvVdjdM9y L5VCplUtE63m5z6pahHPR71Pnb+BGjKWOvYTCcmo1aN8nMwR0tkjGuTRJUcxQUVVCYZW VdgcSTEH3bKmdgidErGcaNeNz0VbBI2MKTnXhzb0vtmNJL7p3LDff3fFbP3sz8qbLVJ8 DlG8nSRtmsSUJpM9J0gNHLGL5ACS2RUV7v9MRPTM00HYnY6N3Jj7pM+lwAXDw+bgLV1U mdOw== 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=44yiA3ypd9Z9fwxLK92nJoDxSjcY2FUyKf3kzqwUJOc=; b=otJBBJPsAj8XeE5y68MB6HQX4sW2tYo8l0RG8allH91p8+VZiXicV3Ea0LNNEZdcav FVEgf+JkgPTCfpOZPDp80zsul7trJ1F3rX8oPTn3heidEEJF7QWP+kDHF3VSWuBrJ5Il po8Hckzdxs4GNx1rtHzW3/47CJf/nkxTQFpMBiiSRGD0cUPAsbdlcjRBnt8Sn8A6B6g9 AUlahld+qcnhn4k3QomaFQxJJ8a9yI71czgYNkAITDCGl04+h7N8PKG8orJBd3tfgZ8p +c0M5MjR4ynCESnfGBFZc/lhC8koCAcO6M++r3/Dhtykj+eUoz+XKJCWV2C7dbduQUhL sP9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=iVwq6CfN; 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=REJECT sp=REJECT dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bk20si4402583ejb.203.2021.02.25.14.23.56; Thu, 25 Feb 2021 14:24:18 -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=@android.com header.s=20161025 header.b=iVwq6CfN; 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=REJECT sp=REJECT dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233659AbhBYWWy (ORCPT + 99 others); Thu, 25 Feb 2021 17:22:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233443AbhBYWR6 (ORCPT ); Thu, 25 Feb 2021 17:17:58 -0500 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33B6CC061225 for ; Thu, 25 Feb 2021 14:17:15 -0800 (PST) Received: by mail-qk1-x72d.google.com with SMTP id d20so6287882qkc.2 for ; Thu, 25 Feb 2021 14:17:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=44yiA3ypd9Z9fwxLK92nJoDxSjcY2FUyKf3kzqwUJOc=; b=iVwq6CfNSEWonjlkLJQXRi/Cm0iUxxT/lq17x1VuDi2jMuBd5UqiT0VF1uybRg1VRq zfnjXy9mkKEQolQC+sxlLW19vUBXi5GCKfnC8K8QDhVNbb2hpjgO8eGnL/KJWEV6lJCy 69Nos5MsEt5Ost6aGeqeUrd/QVHVj9AwlF9wHBMBlJdS/NshrnNbRPfyqgzcF4zkDK7G 3k7tN4cirrQD5EYAmob3YmlDYeddz8ZzveMrgQIvOsyAExDT8YN/DrOqJDmdCeJ8hFvG uZrCBhW9p3WJS9qYlkeLTBe0hNhjgjwlxKLkFGg8aFWtPyjj45YOu9NbfWsbsGZYOfyo 6f/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=44yiA3ypd9Z9fwxLK92nJoDxSjcY2FUyKf3kzqwUJOc=; b=OA60FjBFSWx9nPsKn/cRTPkTCp6vNYHSDMtvUbLRaX4AIZ8vuoGFr29zjaasiwPXUs s2I44Xlc0IVu1Ywx29D8RuQBl/BDGqSSWyD1PCZfNtAx3HOBzZGIXUTU5rK4yLi+H4hm vrfe/4C4R3F1h8vXWFy0g3jhfhBQU1sgAtwz2R5Y18yjjCRdRgrUtlzVzacOKKYXWEit Nyu+KYtEoGQ0c94y3kC3oX126ohOsI6jCH9X9SpZTKnCFIGTQqUgiLiJTDMWeCHwKDIH Q/HxJ5qBtSdfVuL0Y0R1tdRv/IgDm2HuyNhZ/d0FJ4QqPVx+nYdxAT7AKH9/pOGmq3cP pN6w== X-Gm-Message-State: AOAM5312IPns488zckADh3kdkrS6r5+8hsb2PlXKCPSwOTTnY51bdqzL Uw7CsCGXclTrNgQZ0786rTUTF5TcdT2qAtPPItt98w== X-Received: by 2002:ae9:c00e:: with SMTP id u14mr4794568qkk.482.1614291434386; Thu, 25 Feb 2021 14:17:14 -0800 (PST) MIME-Version: 1.0 References: <20210214000611.2169820-1-zzyiwei@android.com> In-Reply-To: From: =?UTF-8?B?WWl3ZWkgWmhhbmfigI4=?= Date: Thu, 25 Feb 2021 14:17:04 -0800 Message-ID: Subject: Re: [PATCH] kthread: add kthread_mod_pending_delayed_work api To: Petr Mladek 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 24, 2021 at 1:34 AM Petr Mladek wrote: > > 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 Thanks for the pointers! I'll explore further with scheduling folks.