Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp244382lqc; Thu, 29 Feb 2024 16:35:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUE58T2I3XaXbfnNNyJVehs2d2Hacq1XWyC7/hu6B7O4gyIo7VqgLef86AzeY2Lu/IOYECIPskzFHpD4GuElRUyvvaEOF6Qf3cajLwFcQ== X-Google-Smtp-Source: AGHT+IE/xAvm+9vdC0QIqjdF0mUgtBV5djAxc3iKXuqYDYSlZ2A6XjW/x+yEenrwLtifL2ja0uVG X-Received: by 2002:a17:906:eb0e:b0:a3f:2596:790c with SMTP id mb14-20020a170906eb0e00b00a3f2596790cmr470318ejb.8.1709253320022; Thu, 29 Feb 2024 16:35:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709253320; cv=pass; d=google.com; s=arc-20160816; b=M02+MaHpMfHuICMM8UY7utTFEI57AxwHZNfaYR6nVn7K+5kpAhjxf7dfTS+uE3HNgr L72HOveCsKX4RmVlBryQsyqcF1wSDGA2I4JirNZzNj0Heqvem7KVqBnj7TgqLcb6ZxeU blWXCpx8cled1Lk2BuF94gorp5Owdv53VAFw5cmJEQtWUszibTaPHDZO/HLh7lkCJWeG bfuzIKnynyA8CE2Snj9akkAwd0iSwRPY7K3q+SdWJ0p70wpof5zfcS8pgEsH4fxY6cT0 woxOBdHlCz5LWGRlctqA8FS20NmRxUYquaYQ/1c76U8pclZ7YZNBYti2IfaliMPK8tHi u6Rg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=OetB1tcYOFnjN6t/6RngLGag3XA6vggjbInpmmsaKcE=; fh=ytoB4ZllTBR/6RA5DLxf8JJMH+LRRZSSBRAyCL+97vU=; b=h99t3ZTCc6hfDT9HUyAh9RUuEiyif6Nv69OW6XDy3E87cCBDhXnBXMND5Iz6DzuXCr y5UfG6x6bq1PifdGE6pBntt5mFWC217GslmZ6c6gwhH2dF5Grh8SqEKuFhLzB1DaFI3f 9K08XMKDoMJmJJ8wJt5ev7kPI/iuE3DdB5FY8/oJqCXxfb0+rT4ItTpr18hq5b3OzDFD RMldiP9E3iQJl1P9EXuzykmOF1fAb1zzhEEt0kiwzY5yYl255n6eFDC10BBtkDsbsPzm DhpUTA0sjaX2ZXeddmp0SkIkv79OKyCKik768MUYttqyFQhjyQdTDn0itaVBIH+olHMR J6Fg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=T8tNM22X; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-87738-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87738-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id jg11-20020a170907970b00b00a41308b6bdasi1004652ejc.260.2024.02.29.16.35.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 16:35:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87738-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=T8tNM22X; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-87738-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87738-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 918841F237CA for ; Fri, 1 Mar 2024 00:35:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 047022572; Fri, 1 Mar 2024 00:35:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="T8tNM22X" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B11981FAB for ; Fri, 1 Mar 2024 00:35:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709253313; cv=none; b=FPXX5BRFrCj7FN52VfxthqSZ0o7gzbS6D/DxN384LGtzii6A3ZBKBlnwHRAwVpx+15CTgRaDKDz8uYa0K2oMsya1lEK2BXGjzYqf94+hnI8IQii+3KN8u1BSeotKPBcC1MXlsnDBl4oqnAXKF86h7SDSutDQ6qwqw2MeLL6Cx8k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709253313; c=relaxed/simple; bh=ZD9CfVPw76C//U5gqjrmuX+/zXDZnhaO8eUOwWKoqXM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=qa1pXvgFSsEOAtekySMTxzcY7aWXWbd74lhsIdgm7qYqWVGzOc2AHNChgT0JWmo+KpT2MYP530gAzrWCcafT2SNtR54os0Iy2u7GDz3rbKWr9O/BftFoy/YlnAgDT/sjftLQHgbYMnXYQAtU1ys2uEJ3wxsw5VlRNjxNFezKp1U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=T8tNM22X; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709253312; x=1740789312; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=ZD9CfVPw76C//U5gqjrmuX+/zXDZnhaO8eUOwWKoqXM=; b=T8tNM22XZedH6SBjYHxqOeN6G1c/weDxIvrjQn8HajNCwnyCt2MLkAvY +j/AzCT1madROexubU8BL7QzLTnrWgPpVsQE8bMApy3GW8+IVmqsc4hcM EPVXpF6zxUezbnwY0KX57jYfCrKP1/qRWnptbhZuqA/59qBINqRrLZAA/ od3D3wVmk/I1do6+OI/lgr5X3UBY/C3zfkbYhfPXJPGukASAoyiHsSjz1 AFwjP9Mps7BpPxpGqVKyN05O6oqTWpAYziR/Lz/h0A0yRN9pako7bquVl RrhKX1PKHykoopRjn4VwKgp4US2YRGA8K470YFkrEsBI6BQTjlQroI2LY A==; X-IronPort-AV: E=McAfee;i="6600,9927,10999"; a="15184500" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="15184500" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 16:35:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="12599031" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 16:35:07 -0800 From: "Huang, Ying" To: David Hildenbrand Cc: Byungchul Park , linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel_team@skhynix.com, akpm@linux-foundation.org, vernhao@tencent.com, mgorman@techsingularity.net, hughd@google.com, willy@infradead.org, peterz@infradead.org, luto@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, rjgolo@gmail.com Subject: Re: [RESEND PATCH v8 0/8] Reduce TLB flushes by 94% by improving folio migration In-Reply-To: <54053f0d-024b-4064-8d82-235cc71b61f8@redhat.com> (David Hildenbrand's message of "Thu, 29 Feb 2024 10:33:44 +0100") References: <20240226030613.22366-1-byungchul@sk.com> <20240229092810.GC64252@system.software.com> <54053f0d-024b-4064-8d82-235cc71b61f8@redhat.com> Date: Fri, 01 Mar 2024 08:33:11 +0800 Message-ID: <87wmqmbxko.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii David Hildenbrand writes: > On 29.02.24 10:28, Byungchul Park wrote: >> On Mon, Feb 26, 2024 at 12:06:05PM +0900, Byungchul Park wrote: >>> Hi everyone, >>> >>> While I'm working with a tiered memory system e.g. CXL memory, I have >>> been facing migration overhead esp. TLB shootdown on promotion or >>> demotion between different tiers. Yeah.. most TLB shootdowns on >>> migration through hinting fault can be avoided thanks to Huang Ying's >>> work, commit 4d4b6d66db ("mm,unmap: avoid flushing TLB in batch if PTE >>> is inaccessible"). See the following link: >>> >>> https://lore.kernel.org/lkml/20231115025755.GA29979@system.software.com/ >>> >>> However, it's only for ones using hinting fault. I thought it'd be much >>> better if we have a general mechanism to reduce the number of TLB >>> flushes and TLB misses, that we can ultimately apply to any type of >>> migration, I tried it only for tiering for now tho. >>> >>> I'm suggesting a mechanism called MIGRC that stands for 'Migration Read >>> Copy', to reduce TLB flushes by keeping source and destination of folios >>> participated in the migrations until all TLB flushes required are done, >>> only if those folios are not mapped with write permission PTE entries. >>> >>> 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 migrc mechanism so as to perform TLB flush >>> required right away. >>> >>> I observed a big improvement of TLB flushes # and TLB misses # at the >>> following evaluation using XSBench like: >>> >>> 1. itlb flush was reduced by 93.9%. >>> 2. dtlb thread was reduced by 43.5%. >>> 3. stlb flush was reduced by 24.9%. >> Hi guys, > > Hi, > >> The TLB flush reduction is 25% ~ 94%, IMO, it's unbelievable. > > Can't we find at least one benchmark that shows an actual improvement > on some system? > > Staring at the number TLB flushes is nice, but if it does not affect > actual performance of at least one benchmark why do we even care? > > "12 files changed, 597 insertions(+), 59 deletions(-)" > > is not negligible and needs proper review. And, the TLB flush is reduced at cost of memory wastage. The old pages could have been freed. That may cause regression for some workloads. > That review needs motivation. The current numbers do not seem to be > motivating enough :) -- Best Regards, Huang, Ying