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 5F8C6C433F5 for ; Mon, 21 Feb 2022 08:57:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB96D8D0002; Mon, 21 Feb 2022 03:57:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D6A728D0001; Mon, 21 Feb 2022 03:57:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C31EB8D0002; Mon, 21 Feb 2022 03:57:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id B562B8D0001 for ; Mon, 21 Feb 2022 03:57:06 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 810442D7 for ; Mon, 21 Feb 2022 08:57:06 +0000 (UTC) X-FDA: 79166182452.04.BB58FD7 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf27.hostedemail.com (Postfix) with ESMTP id C5BFB40002 for ; Mon, 21 Feb 2022 08:55:13 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A83C7210F7; Mon, 21 Feb 2022 08:55:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1645433712; 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=LUrIgAk+aJhrM5t+S1YG62SjatqnJIxam/q/SPE6sz0=; b=GZXQc3KC7uHsZNDNR5bIuR62yqjIJHx3BcEpZsaDbSHrvOHd8yfqWRFcIV14cTqHQJ5VfF +lfbfTsw4UbBU4dVCx+8TGogei6sAbpYL4pKxshnxjOAyKEWnzmRKJ7q5BoL+2j4Vfvpxs 9xWQzgLLdjtg9xvgaz0CguJxMq4AUSU= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 73090A3B81; Mon, 21 Feb 2022 08:55:12 +0000 (UTC) Date: Mon, 21 Feb 2022 09:55:12 +0100 From: Michal Hocko To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, peterz@infradead.org, guro@fb.com, shakeelb@google.com, minchan@kernel.org, timmurray@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH 1/1] mm: count time in drain_all_pages during direct reclaim as memory pressure Message-ID: References: <20220219174940.2570901-1-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220219174940.2570901-1-surenb@google.com> X-Rspamd-Queue-Id: C5BFB40002 X-Stat-Signature: 3rgwrnbmjzqk3fdzx7zj4kkj9euno6go Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=GZXQc3KC; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf27.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1645433713-643204 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat 19-02-22 09:49:40, Suren Baghdasaryan wrote: > When page allocation in direct reclaim path fails, the system will > make one attempt to shrink per-cpu page lists and free pages from > high alloc reserves. Draining per-cpu pages into buddy allocator can > be a very slow operation because it's done using workqueues and the > task in direct reclaim waits for all of them to finish before > proceeding. Currently this time is not accounted as psi memory stall. > > While testing mobile devices under extreme memory pressure, when > allocations are failing during direct reclaim, we notices that psi > events which would be expected in such conditions were not triggered. > After profiling these cases it was determined that the reason for > missing psi events was that a big chunk of time spent in direct > reclaim is not accounted as memory stall, therefore psi would not > reach the levels at which an event is generated. Further investigation > revealed that the bulk of that unaccounted time was spent inside > drain_all_pages call. It would be cool to have some numbers here. > Annotate drain_all_pages and unreserve_highatomic_pageblock during > page allocation failure in the direct reclaim path so that delays > caused by these calls are accounted as memory stall. If the draining is too slow and dependent on the current CPU/WQ contention then we should address that. The original intention was that 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 behind other unrelated work. -- Michal Hocko SUSE Labs