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 4199DC4332F for ; Wed, 1 Nov 2023 03:09:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A57938D0032; Tue, 31 Oct 2023 23:09:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E09C8D0001; Tue, 31 Oct 2023 23:09:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A6C28D0032; Tue, 31 Oct 2023 23:09:04 -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 786078D0001 for ; Tue, 31 Oct 2023 23:09:04 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5710E160692 for ; Wed, 1 Nov 2023 03:09:04 +0000 (UTC) X-FDA: 81407903808.04.A65ECB3 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by imf05.hostedemail.com (Postfix) with ESMTP id 0FE0D10000B for ; Wed, 1 Nov 2023 03:09:00 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=jCjj0IWZ; spf=pass (imf05.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698808141; a=rsa-sha256; cv=none; b=WIyR2lPZuKtnF3I4vdknKpzYxLGOimv8cqDOYeIR6WcFqLveV2RG1n7SHDDiUbpiYNO/JW oKjWBZgowmtj3Z2qzIp7ufiVAfTtNesL/dnrLysH7ICVu0Rbih1mwySLEppIs4OrNlpWBW kLA6uQFG8PG0dYtb6zuRqh1GcVnNLvM= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=jCjj0IWZ; spf=pass (imf05.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698808141; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Yi8M41v5JjpwPXkiTOfPEzBFN0Vy7pywHD6+kdsqvIM=; b=hRJVWMWL4GgS8mZL/5NIQ4/Za+u5T+3HrHh8+3j2t2oKuAmZA2Mv8oVKlsZqDj9d22txBw LAb9O4jpPDjEHTgy2OieAIJLg5tUDz6r2qOEvbYqM+Y9tf/xTd+q8Vsuh/7XdvT63SpbIZ xeK2t4FJb0ZBuudXl3jxoTuHB+qHLDQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698808141; x=1730344141; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=7oU5zP/ORh3VkaRH+O4IqYYm4jA/RodQFLfi2B7JOSo=; b=jCjj0IWZ2WK790KOfNG52F+UdvqO0hWffM6yB1fVeQQmhZpKhYsPs6Rz UPBqr5AilhJW+c1MJuZ2t8TGIQFdn4ugcROeD/iIWAvJ8wkCd1XK/ajBL YDDC44qiOUxgG/bgY5P7t/dymrL9P0PNcE4Z2Sbsji1L0N4Ormu1ecBKr l4W4tFnB3KO41UxnuMxj9ARlB1+yEzvRbcj632jXvYwj815pcXD/7Poue chQyuBHsymaLccBQEztXGewMCeNgSYpkfqfk2TqiVq9QrAqEgRcTrTIXN fiuyXIiveq17mz4FVTsgJLpsLwI44LCmqa76wgX0+dldJCh5+0K9R2miZ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="474664462" X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="474664462" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2023 20:08:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="884409636" X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="884409636" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2023 20:08:53 -0700 From: "Huang, Ying" To: Byungchul Park Cc: David Hildenbrand , , , , , , , , , , , , , , , Subject: Re: [v3 2/3] mm: Defer TLB flush by keeping both src and dst folios at migration In-Reply-To: <20231030095803.GA81877@system.software.com> (Byungchul Park's message of "Mon, 30 Oct 2023 18:58:03 +0900") References: <20231030072540.38631-1-byungchul@sk.com> <20231030072540.38631-3-byungchul@sk.com> <20231030095803.GA81877@system.software.com> Date: Wed, 01 Nov 2023 11:06:51 +0800 Message-ID: <87edha6uk4.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 0FE0D10000B X-Stat-Signature: by15pterugrxm4xx4tt56he7dm13rn5x X-Rspam-User: X-HE-Tag: 1698808140-853118 X-HE-Meta: U2FsdGVkX18+3q9qZUNbcNprheloM816y+1pReUBFcx8owFN4bUose8N52YC/GHiQ34mAt4GzrFVwc/0o4bbl1EApnKa0FT5pzfpZ+U0m0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d0jyPn4mTY= 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: List-Subscribe: List-Unsubscribe: Byungchul Park writes: > On Mon, Oct 30, 2023 at 09:00:56AM +0100, David Hildenbrand wrote: >> On 30.10.23 08:25, Byungchul Park wrote: >> > Implementation of CONFIG_MIGRC that stands for 'Migration Read Copy'. >> > We always face the migration overhead at either promotion or demotion, >> > while working with tiered memory e.g. CXL memory and found out TLB >> > shootdown is a quite big one that is needed to get rid of if possible. >> > >> > Fortunately, TLB flush can be defered or even skipped if both source and >> > destination of folios during migration are kept until all TLB flushes >> > required will have been done, of course, only if the target PTE entries >> > have read only permission, more precisely speaking, don't have write >> > permission. Otherwise, no doubt the folio might get messed up. >> > >> > To achieve that: >> > >> > 1. For the folios that map only to non-writable TLB entries, prevent >> > TLB flush at migration by keeping both source and destination >> > folios, which will be handled later at a better time. >> > >> > 2. When any non-writable TLB entry changes to writable e.g. through >> > fault handler, give up CONFIG_MIGRC mechanism so as to perform >> > TLB flush required right away. >> > >> > 3. Temporarily stop migrc from working when the system is in very >> > high memory pressure e.g. direct reclaim needed. >> > >> > The measurement result: >> > >> > Architecture - x86_64 >> > QEMU - kvm enabled, host cpu >> > Numa - 2 nodes (16 CPUs 1GB, no CPUs 8GB) >> > Linux Kernel - v6.6-rc5, numa balancing tiering on, demotion enabled >> > Benchmark - XSBench -p 50000000 (-p option makes the runtime longer) >> > >> > run 'perf stat' using events: >> > 1) itlb.itlb_flush >> > 2) tlb_flush.dtlb_thread >> > 3) tlb_flush.stlb_any >> > 4) dTLB-load-misses >> > 5) dTLB-store-misses >> > 6) iTLB-load-misses >> > >> > run 'cat /proc/vmstat' and pick: >> > 1) numa_pages_migrated >> > 2) pgmigrate_success >> > 3) nr_tlb_remote_flush >> > 4) nr_tlb_remote_flush_received >> > 5) nr_tlb_local_flush_all >> > 6) nr_tlb_local_flush_one >> > >> > BEFORE - mainline v6.6-rc5 >> > ------------------------------------------ >> > $ perf stat -a \ >> > -e itlb.itlb_flush \ >> > -e tlb_flush.dtlb_thread \ >> > -e tlb_flush.stlb_any \ >> > -e dTLB-load-misses \ >> > -e dTLB-store-misses \ >> > -e iTLB-load-misses \ >> > ./XSBench -p 50000000 >> > >> > Performance counter stats for 'system wide': >> > >> > 20953405 itlb.itlb_flush >> > 114886593 tlb_flush.dtlb_thread >> > 88267015 tlb_flush.stlb_any >> > 115304095543 dTLB-load-misses >> > 163904743 dTLB-store-misses >> > 608486259 iTLB-load-misses >> > >> > 556.787113849 seconds time elapsed >> > >> > $ cat /proc/vmstat >> > >> > ... >> > numa_pages_migrated 3378748 >> > pgmigrate_success 7720310 >> > nr_tlb_remote_flush 751464 >> > nr_tlb_remote_flush_received 10742115 >> > nr_tlb_local_flush_all 21899 >> > nr_tlb_local_flush_one 740157 >> > ... >> > >> > AFTER - mainline v6.6-rc5 + CONFIG_MIGRC >> > ------------------------------------------ >> > $ perf stat -a \ >> > -e itlb.itlb_flush \ >> > -e tlb_flush.dtlb_thread \ >> > -e tlb_flush.stlb_any \ >> > -e dTLB-load-misses \ >> > -e dTLB-store-misses \ >> > -e iTLB-load-misses \ >> > ./XSBench -p 50000000 >> > >> > Performance counter stats for 'system wide': >> > >> > 4353555 itlb.itlb_flush >> > 72482780 tlb_flush.dtlb_thread >> > 68226458 tlb_flush.stlb_any >> > 114331610808 dTLB-load-misses >> > 116084771 dTLB-store-misses >> > 377180518 iTLB-load-misses >> > >> > 552.667718220 seconds time elapsed >> > >> > $ cat /proc/vmstat >> > >> >> So, an improvement of 0.74% ? How stable are the results? Serious question: > > I'm getting very stable result. > >> worth the churn? > > Yes, ultimately the time wise improvement should be observed. However, > I've been focusing on the numbers of TLB flushes and TLB misses because > better result in terms of total time will be followed depending on the > test condition. We can see the result if we test with a system that: > > 1. has more CPUs that would induce a crazy number of IPIs. FYI, the TLB flushing IPI number reduces much with commit 7e12beb8ca2a ("migrate_pages: batch flushing TLB") if multiple pages are migrated together. -- Best Regards, Huang, Ying > 2. has slow memories that makes TLB miss overhead bigger. > 3. runs workloads that is harmful at TLB miss and IPI storm. > 4. runs workloads that causes heavier numa migrations. > 5. runs workloads that has a lot of read only permission mappings. > 6. and so on. > > I will share the results once I manage to meet the conditions. > > By the way, I should've added IPI reduction because it also has super > big delta :) > >> Or did I get the numbers wrong? >> >> > #define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages) >> > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h >> > index 5c02720c53a5..1ca2ac91aa14 100644 >> > --- a/include/linux/page-flags.h >> > +++ b/include/linux/page-flags.h >> > @@ -135,6 +135,9 @@ enum pageflags { >> > #ifdef CONFIG_ARCH_USES_PG_ARCH_X >> > PG_arch_2, >> > PG_arch_3, >> > +#endif >> > +#ifdef CONFIG_MIGRC >> > + PG_migrc, /* Page has its copy under migrc's control */ >> > #endif >> > __NR_PAGEFLAGS, >> > @@ -589,6 +592,10 @@ TESTCLEARFLAG(Young, young, PF_ANY) >> > PAGEFLAG(Idle, idle, PF_ANY) >> > #endif >> > +#ifdef CONFIG_MIGRC >> > +PAGEFLAG(Migrc, migrc, PF_ANY) >> > +#endif >> >> I assume you know this: new pageflags are frowned upon. > > Sorry for that. I really didn't want to add a new headache. > > Byungchul