Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp1739765rdb; Thu, 17 Aug 2023 00:01:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUrJVdD20jN2ska1pIie97HE2BRO7ggspyGsi/vsGyPMnTOVEWf5OBoBSKf7MxWrmsmleX X-Received: by 2002:a17:902:ea01:b0:1bb:cf58:531d with SMTP id s1-20020a170902ea0100b001bbcf58531dmr4786522plg.10.1692255706653; Thu, 17 Aug 2023 00:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692255706; cv=none; d=google.com; s=arc-20160816; b=cwzU2Q3hb49FJm+1SwyKvGOp4LZAHAZXmKxICQQzGLH7DBAW9Hgl13uLv1dT3/Bqlr o85NpvWMto3a8GjFT/Gq7DqaDecMhIvBTgShtSSr4RFvwp9tXDTwTmm46/CwTlLVjLni b95WSxrRf6ZCKNbzTxd7utcFEt/gDFfqkN5jMDHona7G42mSEuSEtrmz1Ms7Mv/X+TpI +2eLGnkwLgI7Ezl9b0tQe3XDnzd2AfECgBPTsxrP1e2fQrb0/dy1FOmxleGGJE4EdHYz gTWX7Gtpb7gF/gAdDKpHpDd2/wUf6ABv2AuIGCCQ+QCCIwPpZVj8ZF/rj9e40T4fMh+c RcQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=YANlG6KWxkYx6BTgjMiE6cvWqdHFsHVRSmYcN6y+FRg=; fh=jaUHfWk/HIwS2KQHQWYF7RZzHkoF9NSQttMPykLXMc4=; b=0XKeOr9v6CqX6cvj+Dl2h68dvrZKH10cCAztdSIUktn9ARO+s2iZGBdlquvq40WF8C V5QVLCasM+Bql/UIWu47X8EYhV8CosR221pqk+4nRMVtLYOmfi7P22wpQ22mhrHpFk5t tMM13cQ36Dbyi1mP9UEekji0AuIRCAIGGDpuwQsUiMXwCXbhNCOpUXunFH3bTMvOZ1hu cF2dTG3sVjVS/YcozY6x+J0tuNEFZR9CX/POM6wHRD9yTJi2G/6o0sA7nFszUtz/T4jc JbRx9xwBI0c4awd2OVUUj2HJuO06DCAWMjLn45tQjJ1rDY1Fl47fnJSgsjcMseGggEyS u3hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id le6-20020a170902fb0600b001bbc84f3ba7si12424589plb.282.2023.08.17.00.01.33; Thu, 17 Aug 2023 00:01:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241328AbjHPCn4 (ORCPT + 99 others); Tue, 15 Aug 2023 22:43:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241325AbjHPCnk (ORCPT ); Tue, 15 Aug 2023 22:43:40 -0400 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0665D212B for ; Tue, 15 Aug 2023 19:43:37 -0700 (PDT) X-AuditID: a67dfc5b-d85ff70000001748-09-64dc37d8d9e5 Date: Wed, 16 Aug 2023 11:40:41 +0900 From: Byungchul Park To: "Huang, Ying" Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel_team@skhynix.com, akpm@linux-foundation.org, namit@vmware.com, xhao@linux.alibaba.com, mgorman@techsingularity.net, hughd@google.com, willy@infradead.org, david@redhat.com, peterz@infradead.org, luto@kernel.org, dave.hansen@linux.intel.com Subject: Re: [RFC 2/2] mm: Defer TLB flush by keeping both src and dst folios at migration Message-ID: <20230816024041.GA16281@system.software.com> References: <20230804061850.21498-1-byungchul@sk.com> <20230804061850.21498-3-byungchul@sk.com> <877cpx9jsx.fsf@yhuang6-desk2.ccr.corp.intel.com> <20230816001307.GA44941@system.software.com> <87r0o37qcn.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87r0o37qcn.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRmVeSWpSXmKPExsXC9ZZnoe4N8zspBiu+W1nMWb+GzeLFhnZG i6/rfzFbPP3Ux2JxedccNot7a/6zWpzftZbVYsfSfUwW13c9ZLQ43nuAyeL3D6DsnClWFidn TWZx4PVYsKnUY/MKLY/Fe14yeWxa1cnmsenTJHaPEzN+s3jsfGjpMe9koMf7fVfZPLb+svP4 vEnO4938t2wBPFFcNimpOZllqUX6dglcGZemLmIuOCBecf7cG/YGxlahLkZODgkBE4k3kycx w9i9V3YwgdgsAqoSC1ecYQWx2QTUJW7c+AlWIyKgIfFp4XJ2EJtZYBuTxIJ7DiC2sECMxIkt n8F6eQUsJG73f2fsYuTiEBL4wSixf9cVNoiEoMTJmU9YIJq1JG78ewnUwAFkS0ss/8cBEuYU sJP4fnIy2HxRAWWJA9uOM4HMkRBoZpdYsO0CE8ShkhIHV9xgmcAoMAvJ2FlIxs5CGLuAkXkV o1BmXlluYmaOiV5GZV5mhV5yfu4mRmBMLav9E72D8dOF4EOMAhyMSjy8DAtvpwixJpYVV+Ye YpTgYFYS4e3hvZUixJuSWFmVWpQfX1Sak1p8iFGag0VJnNfoW3mKkEB6YklqdmpqQWoRT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-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 16, 2023 at 09:01:12AM +0800, Huang, Ying wrote: > Byungchul Park writes: > > > On Tue, Aug 15, 2023 at 09:27:26AM +0800, Huang, Ying wrote: > >> Byungchul Park writes: > >> > >> > 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 have only non-writable TLB entries, prevent > >> > TLB flush by keeping both source and destination of folios during > >> > migration, 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. TLB flushes can be skipped if all TLB flushes required to free the > >> > duplicated folios have been done by any reason, which doesn't have > >> > to be done from migrations. > >> > > >> > 4. Adjust watermark check routine, __zone_watermark_ok(), with the > >> > number of duplicated folios because those folios can be freed > >> > and obtained right away through appropreate TLB flushes. > >> > > >> > 5. Perform TLB flushes and free the duplicated folios pending the > >> > flushes if page allocation routine is in trouble due to memory > >> > pressure, even more aggresively for high order allocation. > >> > >> Is the optimization restricted for page migration only? Can it be used > >> for other places? Like page reclaiming? > > > > Just to make sure, are you talking about the (5) description? For now, > > it's performed at the beginning of __alloc_pages_slowpath(), say, before > > page recaiming. Do you think it'd be meaningful to perform it during page > > reclaiming? Or do you mean something else? > > Not for (5). TLB needs to be flushed during page reclaiming too. Can > similar method be used to reduce TLB flushing there too? Hm.. The mechanism can be used in any places where page mapping is changing but it requires not to have write permission that might mess up consistancy with more than one copy of page. JFYI, one of future works is to detect read mostly pages and turn them to read only to make use of them iff it gives a better performance. Byungchul