Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2474795pxb; Tue, 23 Feb 2021 07:57:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0Q3gQP5Q5h0EGJyKWNnTVHB71H1bdo69UNWNvXdlc7FFtEOt1ziPNB/OQVhiu5SpLkNmn X-Received: by 2002:a17:906:2488:: with SMTP id e8mr26544619ejb.121.1614095845398; Tue, 23 Feb 2021 07:57:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614095845; cv=none; d=google.com; s=arc-20160816; b=0tCwzR0WIzelw81Zp6AjGBeqy+2MSW66stMZ0fQb91A1pkEF4TqP1V14dq81x03sm8 UnNX/HYApMJ8x78P1INIyOhf1nnnEXYzkeU75cqCEiGWiTYuxDfxO7ar3A8q3Ke7hDrH 9TPUMZe9F2zO8ystKyNLo7U4wdzGneJNpQE5Omf+mv5eQgxmc1/2GaNkG9JzZckbQ+DM 9lCf+NvpZlkg8NsWnKD9057+MyKM/PhqxxrSmyB9Yx28ZEajsbLlwjodGts9IzQ/VrgX li26BBywChvZn+vyDTc7IxW83utsM8Ob4s7xdOWptFjDu3KtryMqMMJAv7NjupzZ81ef 4yOw== 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=iIaD7EB0kHwmGhOiSeDJ8cIDAETTm0brCjGJJE6ZqfE=; b=LIZCNks09dFe/gr9+aZh+NCOdvnGGs2ULw+1nYnWVALRDBQLsCZcpJawXxEljkqB01 xr3rs5U92Iy1izt+PaqTYI6FtZjlZRki6aF/NqcMzV1JRPUeaprLyQvbnrMWwHAy3GUC d8rvFGGc4L/CGJbPpNYOJ6MCI0ma9g+7MXUtwTP1jxeDf9RReJV+REW0a7OyjltF7fNG F+n6TBZnJCcSsMrE5q5M6KlevvUncFaYEcV1RgBwXTvhB/qccWH7j/iDJIenHntYV9G0 QU3T2HyIsBcI8S8SZXPvy5zd5W2bg0ilzA8Kbt1g9o9ef7+Rb5ENNYAVJcGhMqBNwhKq wA/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=QVTmPRd0; 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 t21si7417988edi.554.2021.02.23.07.57.01; Tue, 23 Feb 2021 07:57:25 -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=QVTmPRd0; 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 S233451AbhBWPxX (ORCPT + 99 others); Tue, 23 Feb 2021 10:53:23 -0500 Received: from mx2.suse.de ([195.135.220.15]:41158 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233459AbhBWPwt (ORCPT ); Tue, 23 Feb 2021 10:52:49 -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=1614095522; 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=iIaD7EB0kHwmGhOiSeDJ8cIDAETTm0brCjGJJE6ZqfE=; b=QVTmPRd0uKQAjxMjh4WZz3Y+qy331zP61h5CvA4CJm2852odx0I0t+BumHt+fvWxP3+mtu SB+vsKC2R7OxI+mB3ezspNiG6mScq2gKKfl7jcEKomqoAutakRMsEHEN2g+c0KnyCkrTPt /YfuESyhfzq/ZnhCMBNZVqt5TFIekBA= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3243CAC1D; Tue, 23 Feb 2021 15:52:02 +0000 (UTC) Date: Tue, 23 Feb 2021 16:52:01 +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 Mon 2021-02-22 16:58:46, Yiwei Zhang wrote: > Since you awesome guys are here, I do have another kthread related > question, and hopefully to get some suggestions: > > Below are the conditions: > 1. The caller threads queuing the work are normal threads(non-RT). > 2. The worker thread is a realtime kernel thread with relatively high prio. > 3. We are not allowed to pin caller threads to fixed cpu clusters. > > Sometimes when the CPU is busy, the worker thread starts preempting > the caller thread, This works as expected. RT tasks have higher priority than normal tasks. > 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. Best Regards, Petr