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 9E479C25B48 for ; Wed, 25 Oct 2023 01:44:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 068D76B0302; Tue, 24 Oct 2023 21:44:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0194C6B0303; Tue, 24 Oct 2023 21:44:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E49956B0304; Tue, 24 Oct 2023 21:44:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D494A6B0302 for ; Tue, 24 Oct 2023 21:44:30 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A6E961A0322 for ; Wed, 25 Oct 2023 01:44:30 +0000 (UTC) X-FDA: 81382289100.05.DB1AD1F Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) by imf22.hostedemail.com (Postfix) with ESMTP id 27C11C0013 for ; Wed, 25 Oct 2023 01:44:24 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf22.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698198269; a=rsa-sha256; cv=none; b=aK7E5fWmBtFBmxOO43NRm/wUYK8Fwq8vS6UOfBrK0CKUY6wHEezmBXXOQCZ35hhImZVFno Tsj4fCclnOkCRxGzgGqi72yZjs1qo78M8EFJqaMaWO/9WfO0OWzd0a7qUKMh431SfPnhRX YDf4Tt5aVCMyWNrRCnwn5rv8f835bms= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf22.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698198269; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+RgdWcLwTfeCVui2uqXn6ymOlDCinvERUTqTei9nFc8=; b=P4GcZBQSFlLRPMmTSlozbbfC+Tbgox3teNyZ6qsaIt11/nJD4uYioDaH8p5YFukrbLnUHm BhT50/Dd+LW2JWe9rJvg3r2GL8tC8BS8peata+x5DqrCFiTBZ0/DqfNsAW1ib2NxZTrZXJ LUWMwMzitPdtGo4jufquEieZ9DyLWMQ= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VusiUBA_1698198257; Received: from 30.97.48.63(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VusiUBA_1698198257) by smtp.aliyun-inc.com; Wed, 25 Oct 2023 09:44:18 +0800 Message-ID: Date: Wed, 25 Oct 2023 09:44:34 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] arm64: mm: drop tlb flush operation when clearing the access bit To: Kefeng Wang , catalin.marinas@arm.com, will@kernel.org Cc: akpm@linux-foundation.org, v-songbaohua@oppo.com, yuzhao@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 27C11C0013 X-Stat-Signature: gob4amap6ypahx8r4h1rjfa7e9yr9y8n X-Rspam-User: X-HE-Tag: 1698198264-755435 X-HE-Meta: U2FsdGVkX1+jUPVeJwCT4Zw2/ulxQIozGF1s4o7EUn334GQ+o1VoZkh4gFWGFNnIVnyeDTg5a6p3oBh4T0Bdg0L8UtcdSiYGGp8RBAaWigS6KTpWpLY+LjxmYJoCNZFYOt5HdySQJwOEb+FCPzzUyf3T7gUsKsTpRfBxdq/nnJY17dWOFZ2C2QX80jrp/hNk2vT8phSVLIpDAn2NHMHX7lApUT5ruPPG4EREPo+FVw+tf06+2+WC22d0fH+UFSkX8SpMi3ofwmcJ8fLsqQ8ZNK8yGT591Dr6LYOquY3Qlo/NIuUwtoSDJDxJO7CgoEPrNWtFoqOXB2/AySG1jUj2fgyiDxiTkZJF6NFgaOyU1qNVOUOBLVZDDD612NPo8qOAjoV+K7fKGXtWs0OvTNUGQHNr7hRkswOwj3q0lOqBslTibvT6e6BXEnBgrRkyWVYr5TXZvu2syQZoOF4dLf3UaG45ThD9Q2kdB+2heiKBeX89IqUHATEJ1Dn0C+XbqfRFW+yavT+HPFB/zxv5bNzTmpmHQab/XdA5msiGIZ6oChezXjeoyiWsVbNmNQkpPR9g3LLk4P4dGcl02/wwnTMsv77zkx4uak35w9XpADrrg+NE/62uzxOg2uG9gyLNYWF3G0bETDMlODTChmqfrkMW9EqMv56FTOBkvEfnoWuFsByFWrxPzSYMa4WM9ZctDUz0I3bSA225wukJU9UGFd2yCtMpU5yBAUpP4C4SSwvvnwX2idmpl3lsSNQFp21SQVdiQmRdHx+ZiWaTkIln1iqxJUr7PhYeiaUnJL2nxropBaJ6/qGzICZdZJzE44zxL044X5ILr8XPqJ6VhKUvsgvpd/oljsnDWcZ71aLZGVdMvZpOOz5dikQ1F5oAbExGVSoQNBF2l4jWkNFasHdYkGIZsS1prYol7L28qcVRqmHSLtziZJgwmjDYXh4X/Fkv6mToiFZtK8RWqnuHkQdD27R 6NiBIqn4 W96UbgORCzBpqtiIbDg/7iyVvx0q8RCw9Le5gQ5/8UUvIlB+DAgFn60JT4Cu28hSdiajZ 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: On 10/24/2023 9:48 PM, Kefeng Wang wrote: > > > On 2023/10/24 20:56, Baolin Wang wrote: >> Now ptep_clear_flush_young() is only called by folio_referenced() to >> check if the folio was referenced, and now it will call a tlb flush on >> ARM64 architecture. However the tlb flush can be expensive on ARM64 >> servers, especially for the systems with a large CPU numbers. >> >> Similar to the x86 architecture, below comments also apply equally to >> ARM64 architecture. So we can drop the tlb flush operation in >> ptep_clear_flush_young() on ARM64 architecture to improve the >> performance. >> " >> /* Clearing the accessed bit without a TLB flush >>   * doesn't cause data corruption. [ It could cause incorrect >>   * page aging and the (mistaken) reclaim of hot pages, but the >>   * chance of that should be relatively low. ] >>   * >>   * So as a performance optimization don't flush the TLB when >>   * clearing the accessed bit, it will eventually be flushed by >>   * a context switch or a VM operation anyway. [ In the rare >>   * event of it not getting flushed for a long time the delay >>   * shouldn't really matter because there's no real memory >>   * pressure for swapout to react to. ] >>   */ >> " >> Running the thpscale to show some obvious improvements for compaction >> latency with this patch: >>                               base                   patched >> Amean     fault-both-1      1093.19 (   0.00%)     1084.57 *   0.79%* >> Amean     fault-both-3      2566.22 (   0.00%)     2228.45 *  13.16%* >> Amean     fault-both-5      3591.22 (   0.00%)     3146.73 *  12.38%* >> Amean     fault-both-7      4157.26 (   0.00%)     4113.67 *   1.05%* >> Amean     fault-both-12     6184.79 (   0.00%)     5218.70 *  15.62%* >> Amean     fault-both-18     9103.70 (   0.00%)     7739.71 *  14.98%* >> Amean     fault-both-24    12341.73 (   0.00%)    10684.23 *  13.43%* >> Amean     fault-both-30    15519.00 (   0.00%)    13695.14 *  11.75%* >> Amean     fault-both-32    16189.15 (   0.00%)    14365.73 *  11.26%* >>                         base       patched >> Duration User         167.78      161.03 >> Duration System      1836.66     1673.01 >> Duration Elapsed     2074.58     2059.75 >> >> Barry Song submitted a similar patch [1] before, that replaces the >> ptep_clear_flush_young_notify() with ptep_clear_young_notify() in >> folio_referenced_one(). However, I'm not sure if removing the tlb flush >> operation is applicable to every architecture in kernel, so dropping >> the tlb flush for ARM64 seems a sensible change. > > At least x86/s390/riscv/powerpc already do it, also I think we could Right. > change pmdp_clear_flush_young_notify() too, since it is same with > ptep_clear_flush_young_notify(), Perhaps yes, but I'm still unsure if removing tlb flush for PMD entry is applicable to all architectures. Let's see the discussion in this thread. Thanks.