Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp1175868rdb; Sun, 20 Aug 2023 22:11:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwcdcawbSvsQq2OmlMI9SoJPGULy0DSrLYQV33Lz4urgSsKqzvVcw1qvKuqdfa9XLLVM9o X-Received: by 2002:aa7:d0c4:0:b0:525:53b6:3ef9 with SMTP id u4-20020aa7d0c4000000b0052553b63ef9mr3965551edo.35.1692594683836; Sun, 20 Aug 2023 22:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692594683; cv=none; d=google.com; s=arc-20160816; b=b3cm9BJlWDTHk0tootONpLw6v59o0C/zPgXO+zfN9Q0bY+KIk3RqcJHWcK3xK3sqC7 uk2C+TSUET3kCQsw5ebLFQI0gtmcutWT9HsG3xdm/xnGwoAKuXqIsPooYXK2rxwyYQBy qY+t6PIcBNqtZLobmX64qIem2ZdefDIYLaqHqkF17259rcjD7efHu/Ms9HvbNsYzXzym S1NnJPMBdTi1QZ11kqZXXPshmqway8ZsqMhflv9Ce9wuMQ8V6A5LApev9vFvQfRQVW/0 zEFagYmIpp/X/tqFBs31itN+GTu8WMBHZCeHxj0bAK3LUuH4G+bwlFZ+zvdncKbLC2mr UHFw== 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=a33zBOB34KB+kAMxH48291j7HRUDUxaxCEXe8k4tu/U=; fh=jaUHfWk/HIwS2KQHQWYF7RZzHkoF9NSQttMPykLXMc4=; b=J2NUMvKf+C6/L8RJgka9nj+qq2n1KMaTDBaH2YyD7xutBgqcacRM2X/CN0zA1UTW32 oITW3og6Nv47R9fR1ziiZSGBQDSrx1+1Ft8rDX9fwIh0hSedL+iCz5mHkHjoES3/bd5G yKFWwA2GQafFvQyrl4byurih3oN7ZnTZmq03QAokQ0yOf2OoxQrf6uNA1iDfXOQNhgOu 3vDH6HFabe+rE/8tISUqtkF6pymViRLnRFIwLoiChV4ex0tvNY8cFLfx/2p9+QZ427Yv nSxNBIlLO7XwOtQht5fvSo74t3vU+e2os2bYGNwPZhyhCLywqMC8knq5ElGkR2B+alOc 8AQQ== 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 e12-20020a50fb8c000000b00523c0183e20si5000281edq.683.2023.08.20.22.10.56; Sun, 20 Aug 2023 22:11:23 -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 S232391AbjHUBcT (ORCPT + 99 others); Sun, 20 Aug 2023 21:32:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232381AbjHUBcS (ORCPT ); Sun, 20 Aug 2023 21:32:18 -0400 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2B9BAA3 for ; Sun, 20 Aug 2023 18:31:44 -0700 (PDT) X-AuditID: a67dfc5b-d6dff70000001748-a6-64e2be5bc41e Date: Mon, 21 Aug 2023 10:28:05 +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: <20230821012804.GA43847@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+NgFprEIsWRmVeSWpSXmKPExsXC9ZZnoW70vkcpBq8+6FjMWb+GzeLFhnZG i6/rfzFbPP3Ux2JxedccNot7a/6zWpzftZbVYsfSfUwW13c9ZLQ43nuAyeL3D6DsnClWFidn TWZx4PVYsKnUY/MKLY/Fe14yeWxa1cnmsenTJHaPEzN+s3jsfGjpMe9koMf7fVfZPLb+svP4 vEnO4938t2wBPFFcNimpOZllqUX6dglcGbvO9bMV/BKteDrlKVsD4xuBLkZODgkBE4knrYfZ YeznG+6xgNgsAqoSP/YfYQWx2QTUJW7c+MkMYosIaEh8WrgcrJ5ZYBuTxIJ7DiC2sECMxIkt n5lAbF4BC4lrD9sZuxi5OIQEfjBK7N91hQ0iIShxcuYTFohmLYkb/14CNXAA2dISy/9xgIQ5 Bewkvp+cDDZfVEBZ4sC240wgcyQEmtklNp6/yQhxqKTEwRU3WCYwCsxCMnYWkrGzEMYuYGRe xSiUmVeWm5iZY6KXUZmXWaGXnJ+7iREYU8tq/0TvYPx0IfgQowAHoxIPb4LMoxQh1sSy4src Q4wSHMxKIrzS3x+mCPGmJFZWpRblxxeV5qQWH2KU5mBREuc1+laeIiSQnliSmp2aWpBaBJNl 4u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AA X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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? If you were talking about unmapping for swap while reclaiming, then I think yes. The case can also take benefit from CONFIG_MIGRC. Byungchul