From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F390C433EF for ; Thu, 3 Mar 2022 02:59:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBA878D0002; Wed, 2 Mar 2022 21:59:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C69F38D0001; Wed, 2 Mar 2022 21:59:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B58768D0002; Wed, 2 Mar 2022 21:59:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0198.hostedemail.com [216.40.44.198]) by kanga.kvack.org (Postfix) with ESMTP id A3C9E8D0001 for ; Wed, 2 Mar 2022 21:59:49 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 439D0181CB15F for ; Thu, 3 Mar 2022 02:59:49 +0000 (UTC) X-FDA: 79201570098.31.C0644DE Received: from r3-22.sinamail.sina.com.cn (r3-22.sinamail.sina.com.cn [202.108.3.22]) by imf15.hostedemail.com (Postfix) with SMTP id 6D1E8A0009 for ; Thu, 3 Mar 2022 02:59:47 +0000 (UTC) Received: from unknown (HELO localhost.localdomain)([114.249.61.131]) by sina.com (172.16.97.32) with ESMTP id 62202EEB000061AF; Thu, 3 Mar 2022 10:58:53 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 263655628825 From: Hillf Danton To: Tim Murray Cc: Suren Baghdasaryan , Linux-MM , LKML Subject: Re: [PATCH 1/1] mm: count time in drain_all_pages during direct reclaim as memory pressure Date: Thu, 3 Mar 2022 10:59:33 +0800 Message-Id: <20220303025933.2265-1-hdanton@sina.com> In-Reply-To: References: <20220219174940.2570901-1-surenb@google.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6D1E8A0009 X-Stat-Signature: msebgp4obkxzgbne34z6jw3x7fyecdat X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf15.hostedemail.com: domain of hdanton@sina.com designates 202.108.3.22 as permitted sender) smtp.mailfrom=hdanton@sina.com X-Rspamd-Server: rspam03 X-HE-Tag: 1646276387-279307 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.001515, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 22 Feb 2022 11:47:01 -0800 Tim Murray wrote: > On Mon, Feb 21, 2022 at 12:55 AM Michal Hocko wrote: > > It would be cool to have some numbers here. >=20 > Are there any numbers beyond what Suren mentioned that would be > useful? As one example, in a trace of a camera workload that I opened > at random to check for drain_local_pages stalls, I saw the kworker > that ran drain_local_pages stay at runnable for 68ms before getting > any CPU time. I could try to query our trace corpus to find more > examples, but they're not hard to find in individual traces already. >=20 > > If the draining is too slow and dependent on the current CPU/WQ > > contention then we should address that. The original intention was th= at > > having a dedicated WQ with WQ_MEM_RECLAIM would help to isolate the > > operation from the rest of WQ activity. Maybe we need to fine tune > > mm_percpu_wq. If that doesn't help then we should revise the WQ model > > and use something else. Memory reclaim shouldn't really get stuck beh= ind > > other unrelated work. >=20 > In my experience, workqueues are easy to misuse and should be > approached with a lot of care. For many workloads, they work fine 99%+ > of the time, but once you run into problems with scheduling delays for > that workqueue, the only option is to stop using workqueues. If you > have work that is system-initiated with minimal latency requirements > (eg, some driver heartbeat every so often, devfreq governors, things > like that), workqueues are great. If you have userspace-initiated work > that should respect priority (eg, GPU command buffer submission in the > critical path of UI) or latency-critical system-initiated work (eg, > display synchronization around panel refresh), workqueues are the > wrong choice because there is no RT capability. WQ_HIGHPRI has a minor > impact, but it won't solve the fundamental problem if the system is > under heavy enough load or if RT threads are involved. As Petr > mentioned, the best solution for those cases seems to be "convert the > workqueue to an RT kthread_worker." I've done that many times on many > different Android devices over the years for latency-critical work, > especially around GPU, display, and camera. Feel free to list the URLs to the latency-critical works as I want to learn the reasons why workqueue failed to fit in the scenarios. >=20 > In the drain_local_pages case, I think it is triggered by userspace > work and should respect priority; I don't think a prio 50 RT task > should be blocked waiting on a prio 120 (or prio 100 if WQ_HIGHPRI) > kworker to be scheduled so it can run drain_local_pages. If that's a > reasonable claim, then I think moving drain_local_pages away from > workqueues is the best choice. A prio-50 direct reclaimer implies design failure in 99.1% products.