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 D0320C4167B for ; Tue, 10 May 2022 18:13:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D9256B0072; Tue, 10 May 2022 14:13:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1893D6B0073; Tue, 10 May 2022 14:13:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0030C8D0001; Tue, 10 May 2022 14:13:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DF1586B0072 for ; Tue, 10 May 2022 14:13:09 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9AC6521BCC for ; Tue, 10 May 2022 18:13:09 +0000 (UTC) X-FDA: 79450630098.22.2218291 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf18.hostedemail.com (Postfix) with ESMTP id DEF801C0093 for ; Tue, 10 May 2022 18:12:58 +0000 (UTC) Received: by mail-pl1-f178.google.com with SMTP id s14so17460580plk.8 for ; Tue, 10 May 2022 11:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=89mc+F3C89QRpIXv+3CREeayukHxq0NE/oSUKuC5Jdg=; b=ks7Gabclb8CM0RM7dDLvohbelK4HdBErQ1SwzXfGzDHBdUTVoAwKwr3HvFAUBT30Ya HdNmwfnG4hYgtWkHjyy7Ni0TxLFq42Gf1YquF9d7MLVsram6xrV4VDwIsPSQfDONIAwn xKtJDiJEn6g3+MbGYaBJp6J7WzdiTmVoU5Ks/vzEMg0DsQbdNmkgnmTv6uYENGt6CoP4 ui09JmdkMRN3iLA/rYds/PBwnFhM2YGd3TGGB8Yo/a97h+mSeFSAAU7CyJdOwTQUTv6+ G4H5zBLXQ6M3mZtx1fQV4AuzzOzkEsnjAyVVwu+VLH0z2aoxW8DZWgGxiOImbHd1Bj5+ kzoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=89mc+F3C89QRpIXv+3CREeayukHxq0NE/oSUKuC5Jdg=; b=zmnIjG8cWqko+LAO/nRAFweB5L8nF95I9ibNS4NTT2/eBQWK1mXsAEyfOfk/stXD2S bj3jbApiBeb2jkRE+ONbMlTpG7tx7Ff2mpyJhAVm6cfi+cAwW74XZ7V/8VYbZ855D5lV SNYOMmOluCSgHNv0rrapQxy0Erm5ntPnDCBjX+rvHjlNedd0+uJySb9fS14I0+Wt6mYW p4na9ss7zFsfvZNCgcauWl0ApmZDi2THG8yaN53Xhp4y1YHhlwBO+bmam5phZ1+KfmLo uHOQlXKafbf0ggpdPbX6C5dE8kXwnv982r/rGRCZFFjWOCiRKtFD9H0D7os66WwnoIaJ cTCw== X-Gm-Message-State: AOAM531tLOCDrQxGk+9j0PKmP5VNXQXQIvgnoh9fkOakv1wBA9JsR5b+ cIiA0tiWUq1pzixTyGeuNcI= X-Google-Smtp-Source: ABdhPJzaAtrw45oMAbtttFRKUqtwzfmtNbQwlV7PxdcyDTiaH8NoGuaA4q8qB2l4uKjEMDNiKJdv1Q== X-Received: by 2002:a17:903:110c:b0:15f:f15:30ec with SMTP id n12-20020a170903110c00b0015f0f1530ecmr11372428plh.162.1652206387970; Tue, 10 May 2022 11:13:07 -0700 (PDT) Received: from google.com ([2620:15c:211:201:c98a:65b0:edca:b69a]) by smtp.gmail.com with ESMTPSA id m8-20020a1709026bc800b0015e8d4eb2c9sm2313024plt.275.2022.05.10.11.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 11:13:07 -0700 (PDT) Date: Tue, 10 May 2022 11:13:05 -0700 From: Minchan Kim To: Mel Gorman Cc: Nicolas Saenz Julienne , Marcelo Tosatti , Vlastimil Babka , Michal Hocko , LKML , Linux-MM Subject: Re: [RFC PATCH 0/6] Drain remote per-cpu directly v2 Message-ID: References: <20220509130805.20335-1-mgorman@techsingularity.net> <20220510092733.GE3441@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220510092733.GE3441@techsingularity.net> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: DEF801C0093 X-Stat-Signature: p9c9txgcndt8hb59togs4jdopm9grf8x Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ks7Gabcl; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf18.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com X-Rspam-User: X-HE-Tag: 1652206378-865329 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 Tue, May 10, 2022 at 10:27:33AM +0100, Mel Gorman wrote: > On Mon, May 09, 2022 at 08:58:51AM -0700, Minchan Kim wrote: > > On Mon, May 09, 2022 at 02:07:59PM +0100, Mel Gorman wrote: > > > Changelog since v1 > > > o Fix unsafe RT locking scheme > > > o Use spin_trylock on UP PREEMPT_RT > > > > Mel, > > > > > > Is this only change from previous last version which has some > > delta you fixed based on Vlastimil and me? > > > > Full diff is below although it can also be generated by > comparing the mm-pcpdrain-v1r8..mm-pcpdrain-v2r1 branches in > https://git.kernel.org/pub/scm/linux/kernel/git/mel/linux.git/ I took the delta when I started testing so the testing result would be valid. Thanks. > > > And is it still RFC? > > > > It's still RFC because it's a different approach to Nicolas' series and > I want at least his Acked-by before taking the RFC label out and sending > it to Andrew. > > > Do you have some benchmark data? > > > > Yes, but as reclaim is not fundamentally altered the main difference > in behavious is that work is done inline instead of being deferred to a > workqueue. That means in some cases, system CPU usage of a task will be > higher because it's paying the cost directly. Sure but the reclaim path is already expensive so I doubt we could see the sizable measurement on the system CPU usage. What I wanted to see was whether we have regression due to adding spin_lock/unlock instructions in hot path. Due to squeeze it to a cacheline, I expected the regression would be just marginal. > > The workloads I used just hit reclaim directly to make sure it's > functionally not broken. There is no change in page aging decisions, > only timing of drains. I didn't check interference of a heavy workload > interfering with a CPU-bound workload running on NOHZ CPUs as I assumed > both you and Nicolas had a test case ready to use. The my workload is not NOHZ CPUs but run apps under heavy memory pressure so they goes to direct reclaim and be stuck on drain_all_pages until work on workqueue run. unit: nanosecond max(dur) avg(dur) count(dur) 166713013 487511.77786438033 1283 >From traces, system encountered the drain_all_pages 1283 times and worst case was 166ms and avg was 487us. The other problem was alloc_contig_range in CMA. The PCP draining takes several hundred millisecond sometimes though there is no memory pressure or a few of pages to be migrated out but CPU were fully booked. Your patch perfectly removed those wasted time. > > The main one I paid interest to was a fault latency benchmark in > the presense of heavy reclaim called stutterp. It simulates a simple > workload. One part uses a lot of anonymous memory, a second measures mmap > latency and a third copies a large file. The primary metric is checking > for mmap latency. It was originally put together to debug interactivity > issues on a desktop in the presense of heavy IO where the desktop > applications were being pushed to backing storage. > > stutterp > 5.18.0-rc1 5.18.0-rc1 > vanilla mm-pcpdrain-v2r1 > 1st-qrtle mmap-4 15.9557 ( 0.00%) 15.4045 ( 3.45%) > 1st-qrtle mmap-6 10.8025 ( 0.00%) 11.1204 ( -2.94%) > 1st-qrtle mmap-8 16.9338 ( 0.00%) 17.0595 ( -0.74%) > 1st-qrtle mmap-12 41.4746 ( 0.00%) 9.4003 ( 77.33%) > 1st-qrtle mmap-18 47.7123 ( 0.00%) 100.0275 (-109.65%) > 1st-qrtle mmap-24 17.7098 ( 0.00%) 16.9633 ( 4.22%) > 1st-qrtle mmap-30 69.2565 ( 0.00%) 38.2205 ( 44.81%) > 1st-qrtle mmap-32 49.1295 ( 0.00%) 46.8819 ( 4.57%) > 3rd-qrtle mmap-4 18.4706 ( 0.00%) 17.4799 ( 5.36%) > 3rd-qrtle mmap-6 11.4526 ( 0.00%) 11.5567 ( -0.91%) > 3rd-qrtle mmap-8 19.5903 ( 0.00%) 19.0046 ( 2.99%) > 3rd-qrtle mmap-12 50.3095 ( 0.00%) 25.3254 ( 49.66%) > 3rd-qrtle mmap-18 67.3319 ( 0.00%) 147.6404 (-119.27%) > 3rd-qrtle mmap-24 41.3779 ( 0.00%) 84.4035 (-103.98%) > 3rd-qrtle mmap-30 127.1375 ( 0.00%) 148.8884 ( -17.11%) > 3rd-qrtle mmap-32 79.7423 ( 0.00%) 182.3042 (-128.62%) > Max-99 mmap-4 46.9123 ( 0.00%) 49.7731 ( -6.10%) > Max-99 mmap-6 42.5414 ( 0.00%) 16.6173 ( 60.94%) > Max-99 mmap-8 43.1237 ( 0.00%) 23.3478 ( 45.86%) > Max-99 mmap-12 62.8025 ( 0.00%) 1947.3862 (-3000.81%) > Max-99 mmap-18 27936.8695 ( 0.00%) 232.7122 ( 99.17%) > Max-99 mmap-24 204543.9436 ( 0.00%) 5805.2478 ( 97.16%) > Max-99 mmap-30 2350.0289 ( 0.00%) 10300.6344 (-338.32%) > Max-99 mmap-32 56164.2271 ( 0.00%) 7789.7526 ( 86.13%) > Max mmap-4 840.3468 ( 0.00%) 1137.4462 ( -35.35%) > Max mmap-6 255233.3996 ( 0.00%) 91304.0952 ( 64.23%) > Max mmap-8 210910.6497 ( 0.00%) 117931.0796 ( 44.08%) > Max mmap-12 108268.9537 ( 0.00%) 319971.6910 (-195.53%) > Max mmap-18 608805.3195 ( 0.00%) 197483.2205 ( 67.56%) > Max mmap-24 327697.5605 ( 0.00%) 382842.5356 ( -16.83%) > Max mmap-30 688684.5335 ( 0.00%) 669992.7705 ( 2.71%) > Max mmap-32 396842.0114 ( 0.00%) 415978.2539 ( -4.82%) > > 5.18.0-rc1 5.18.0-rc1 > vanillamm-pcpdrain-v2r1 > Duration User 1438.08 1637.21 > Duration System 12267.41 10307.96 > Duration Elapsed 3929.70 3443.53 > > > It's a mixed bag but this workload is always a mixed bag and it's stressing > reclaim. At some points, latencies are worse, in others better. Overall, > it completed faster and this was on a 1-socket machine. > > On a 2-socket machine, the overall completions times were worse > > 5.18.0-rc1 5.18.0-rc1 > vanillamm-pcpdrain-v2r1 > Duration User 3713.75 2899.90 > Duration System 303507.56 378909.94 > Duration Elapsed 15444.59 19067.40 > > In general this type of workload is variable given the nature of what it > does and can give different results on each execution. When originally > designed, it was to deal with stalls lasting several seconds to reduce > them to the sub-millisecond range. > > The intent of the series is switching out-of-line work to in-line so > what it should be measuring is interference effects and not straight-line > performance and I haven't written a specific test case yet. When writing > the series initially, it was to investigate if the PCP could be lockless > and failing that, if disabling IRQs could be avoided in the common case. > It just turned out that part of that made remote draining possible and > I focused closer on that because it's more important. > > > I'd like to give Acked-by/Tested-by(even though there are a few > > more places to align with new fields name in 1/6) > > Which ones are of concern? > > Some of the page->lru references I left alone in the init paths simply > because in those contexts, the page wasn't on a buddy or PCP list. In > free_unref_page_list the page is not on the LRU, it's just been isolated > from the LRU. In alloc_pages_bulk, it's not on a buddy, pcp or LRU list > and is just a list placeholder so I left it alone. In > free_tail_pages_check the context was a page that was likely previously > on a LRU. Just nits: all are list macros. free_pcppages_bulk's list_last_entry should be pcp_list. mark_free_pages's list_for_each_entry should be buddy_list __rmqueue_pcplist's list_first_enty should be pcp_list. > > > since I have > > tested these patchset in my workload and didn't spot any other > > problems. > > > > Can you describe this workload, is it available anywhere and does it > require Android to execute? I wrote down above. It runs on Android but I don't think it's android specific issue but anyone could see such a long latency from PCP draining once one of cores are monopolized by higher priority processes or too many pending kworks. > > If you have positive results, it would be appreciated if you could post > them or just note in a Tested-by/Acked-by that it had a measurable impact > on the reclaim/cma path. Sure. All patches in this series. Tested-by: Minchan Kim Acked-by: Minchan Kim Thanks.