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 E840AC433F5 for ; Thu, 24 Feb 2022 07:10:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 428DD8D0002; Thu, 24 Feb 2022 02:10:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D82E8D0001; Thu, 24 Feb 2022 02:10:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C7028D0002; Thu, 24 Feb 2022 02:10:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 07F218D0001 for ; Thu, 24 Feb 2022 02:10:07 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9375820BFD for ; Thu, 24 Feb 2022 07:10:07 +0000 (UTC) X-FDA: 79176799254.05.B13D316 Received: from mail-ot1-f73.google.com (mail-ot1-f73.google.com [209.85.210.73]) by imf27.hostedemail.com (Postfix) with ESMTP id 2826B40003 for ; Thu, 24 Feb 2022 07:10:07 +0000 (UTC) Received: by mail-ot1-f73.google.com with SMTP id t26-20020a0568301e3a00b005af6b88cf12so803028otr.12 for ; Wed, 23 Feb 2022 23:10:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=0HxuerY811sRCg0Jfk4JZiV8GyWj5zsy+8XByk2p3uE=; b=h044Pz91gVuphvakkKNhmZHHx6f6K0RMTVPCT1RY4ZuAIIRan7B3CdSOs0SFunl1gd I3V35Gy1MLUYGHta+YPdVS7oD/v2rnkX5ACpfzrdFQaEAbP61qP1dpwR+pKVWCz+KQj4 kQevPpY1kjJ9v2JyI6mmU5fJmgpxY138W7S8zD6w0fTekRTcbVKexQpUfrh3klr5HeG1 bhjeN6fIlAJ8T0KFgpq1AxOiVZC2PM2r5o+WuYNIX+qeRqQl4nAthw8n4NTG9SeQiVF3 /Z8jUuCCvxoi6aDec1q6eL5HFiFKGSYGWwJFIlpo4QCACWab5smKNaimXFA1IKCFL2kM fxcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=0HxuerY811sRCg0Jfk4JZiV8GyWj5zsy+8XByk2p3uE=; b=dNAhL7FAQ5SM9bUutnGMmd0zlvFNhdD/ScFpfEb0cH/n1SvOvts0bsBi8WWCD29AzU H5q+zyqqDaIR6jvrpnfdMwZLJ86SR6pmZ96LImu2D1l8UnXDcxI/CuYRKSklyCAdYH93 AyvdhAHy4umkTMttM30vg1YPn7X4Q+XzBy3kmaoxjbnD6cDwU0iQEEc9+8pY4BsxUxZl rPcYkttdal0I/vJ8q9cs5EWMfbh2oIywSLMxkKzqN16mVrh5OIoDvr5chko0jQzNQLgU stg1rygNZEW1Lnc9w39tSA+qaOKccvT8KxuChOIXXGEs2rCyw9lJh6K+cM5u3L+Q/B8F bwkg== X-Gm-Message-State: AOAM5317K4LSq1VMwwuymX5/uyhsBIe1SzYWtjuamDfQhkKAZVxjnFGx Yl0/QQYZG/u3xJIX1FYwyogdZjNP1GEw8A== X-Google-Smtp-Source: ABdhPJwF/l64e7Ik7fg0Dqg/2ETqDfmi125huEghgMaJKwhrrLZwspr/Y4tMqgu4emOFahgp0JWO+cpz9Ee44Q== X-Received: from shakeelb.svl.corp.google.com ([2620:15c:2cd:202:8c61:13e8:87c2:e5f0]) (user=shakeelb job=sendgmr) by 2002:aca:f0d:0:b0:2d4:e810:4249 with SMTP id 13-20020aca0f0d000000b002d4e8104249mr6476444oip.37.1645686606011; Wed, 23 Feb 2022 23:10:06 -0800 (PST) Date: Wed, 23 Feb 2022 23:10:02 -0800 In-Reply-To: <20220223194812.1299646-1-surenb@google.com> Message-Id: <20220224071002.w3r3at3zhccwu6p6@google.com> Mime-Version: 1.0 References: <20220223194812.1299646-1-surenb@google.com> Subject: Re: [PATCH v3 1/1] mm: count time in drain_all_pages during direct reclaim as memory pressure From: Shakeel Butt To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@suse.com, pmladek@suse.com, peterz@infradead.org, guro@fb.com, minchan@kernel.org, timmurray@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes X-Rspamd-Queue-Id: 2826B40003 X-Stat-Signature: k9n64jwxy8dzw1en93cperr6wnzbtx7g Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=h044Pz91; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf27.hostedemail.com: domain of 3Ti8XYggKCCEPE7HBBI8DLLDIB.9LJIFKRU-JJHS79H.LOD@flex--shakeelb.bounces.google.com designates 209.85.210.73 as permitted sender) smtp.mailfrom=3Ti8XYggKCCEPE7HBBI8DLLDIB.9LJIFKRU-JJHS79H.LOD@flex--shakeelb.bounces.google.com X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1645686607-875447 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Feb 23, 2022 at 11:48:12AM -0800, 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. > A typical captured case when drain_all_pages path gets activated: > __alloc_pages_slowpath took 44.644.613ns > __perform_reclaim took 751.668ns (1.7%) > drain_all_pages took 43.887.167ns (98.3%) > PSI in this case records the time spent in __perform_reclaim but > ignores drain_all_pages, IOW it misses 98.3% of the time spent in > __alloc_pages_slowpath. > Annotate __alloc_pages_direct_reclaim in its entirety so that delays > from handling page allocation failure in the direct reclaim path are > accounted as memory stall. > Reported-by: Tim Murray > Signed-off-by: Suren Baghdasaryan > Acked-by: Johannes Weiner Reviewed-by: Shakeel Butt