Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2188603rda; Tue, 24 Oct 2023 15:33:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHi0lS984mDJSYUZICewd65guiP4lXjemBpYhSDx4pDSGp7yVEjEZnwxs4hcdfTZCvq6o1i X-Received: by 2002:a05:6358:c8a:b0:168:dd67:2fe5 with SMTP id o10-20020a0563580c8a00b00168dd672fe5mr6901536rwj.8.1698186822063; Tue, 24 Oct 2023 15:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698186822; cv=none; d=google.com; s=arc-20160816; b=jGaR+F6XNV2djevMaRMOhmYMDk4vWor5+7yIwS1VDxzVcN7UqmPBiePeM/95/h6npo C/AeO5eAQVl/e5uub2hF+tqsvwbzBmfwuC/g5cdd0MWZqn6AcYg6AfKhhSA4dALRfr55 3/sLcng6BM01BWpj5pC1+cF32PlC0blqdC+DySheWDYEPNAjg6WJTon3SPtfpf4eXlcp OtzJ79U1UilQ3Fn/l70+lAojPhoZ+JEwnvDBsGsbNrbvvAIgvVyWSWamOVUPvzCKe25L 3pizEEYenYgYhSko7/AOgIBMu0CNph9FlPIBO0JbF1CgSKMdEH2jAMqHtvyz7nBqmqaf zg6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=4iRTEiIAHqdOTFjTizDZPjyhzdJk6A4pywAK9Lo2CAs=; fh=SP1QXsXfVQb9y4QVX8lqP4uibK9VuopIeHhGojOtKy8=; b=uCQsaBCdLoAoi6PVBxjAsZTgWxQHIdPG858HVYPUjQ1K9kYNuxXOvYnmxweDsYfViy yd08b3GFvnF7SiMBgLyy0fzZt0xnnMNNu0f2oOfuKuEzUT16EIPWHQtJXPsAVqzhkmcn d8dY0hFYA05k9sqssxvxqZuV8DIhpIoofpyRgjzb7tdPcBQQa97fzyd1mOK5kBuL9/pX LJ/SbONn9I6hzTlduysYlcNjpu6j29ewe7CKcBnS1lDdAzyt/Iv+RoILPJ01CKTWIkY8 j63FntrNIvZSURQEiiIgdOqqnDGdY2otJYi4S39PV5B4CnyaZlJC653Ote6vYATbC6oz T/lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=u9Vow3dP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id bz19-20020a056a02061300b005b9053cf6f2si221620pgb.163.2023.10.24.15.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 15:33:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=u9Vow3dP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 859CF802A935; Tue, 24 Oct 2023 15:33:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344533AbjJXWd0 (ORCPT + 99 others); Tue, 24 Oct 2023 18:33:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344571AbjJXWdY (ORCPT ); Tue, 24 Oct 2023 18:33:24 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0498199B for ; Tue, 24 Oct 2023 15:33:14 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-53eeb28e8e5so1937a12.1 for ; Tue, 24 Oct 2023 15:33:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698186793; x=1698791593; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=4iRTEiIAHqdOTFjTizDZPjyhzdJk6A4pywAK9Lo2CAs=; b=u9Vow3dPZ4aOOqWvjW2BQYVWZ+wrAmPCRBS8oVS/DIWMHQ8ECo0sBbHComztxC2ZHI KHmSBPdgx57825ZE0fbvZ7jxw3AzjfQznc1/CPjQzjcDi6j+1imoR3HR/SSUFJCaNgsU UREYonF50vCsp9ZgX0hjpTJwYfKb+1IhNTIxevlyQwttBc4K2X7b7ezoDj4SsyYvTZ2l Ddz+1XFpGbCLSLxZNq7KjH9t/BT9POXeznI81evmY6yD7EUTvpUJX0RX2PXCrsriL09v 1GFomSKMr9iCB4siA2OFWFGbH8nMWLvl71cj/U/X6gzIehDypcBgnyExiKB2bWTyqAH4 smZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698186793; x=1698791593; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4iRTEiIAHqdOTFjTizDZPjyhzdJk6A4pywAK9Lo2CAs=; b=O7/8IudWl2w9mM31ujBZs+GJPQqkyfW05NsxB6URvhEWNHGTppXN4Tj5mai/2SQfZs msR6tNWqfrShkmTmgxAwR5z2JZ8EqBjv7ibc1DRuSJ0GZAR0HhVdB+9ttv8XtjvT5DYf NShOSp3pAZuCEjMQ6dnsW6Ss8SgDJOgzJ5p0iIJikX14ybzPl5LfqQaCmv4Az/yPXN0o ijT2hqe/UOkpb4Cew/x8FVnf38HMm+xN9az0YuaAJNlOBtbQUHtcBNrUQVTlqam2XcVx zny4dM/S0jFwUgRDvv+U7B8yMHUaQppUzdsCogagdvaxLzrn+SdRZIAuscbJk50FJgmZ ljug== X-Gm-Message-State: AOJu0YzMbX6Pl6TuOiNhRFPVO9TEN0H9jQtXiCYGCGTuZU4bhosNID2i E3YAl21V319DgnMLL1wHsmNOvQVjc4QKfVbmY+160A== X-Received: by 2002:aa7:df94:0:b0:540:e4c3:430 with SMTP id b20-20020aa7df94000000b00540e4c30430mr311edy.6.1698186789616; Tue, 24 Oct 2023 15:33:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yu Zhao Date: Tue, 24 Oct 2023 16:32:30 -0600 Message-ID: Subject: Re: [PATCH] arm64: mm: drop tlb flush operation when clearing the access bit To: Baolin Wang , Minchan Kim Cc: catalin.marinas@arm.com, will@kernel.org, akpm@linux-foundation.org, v-songbaohua@oppo.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 24 Oct 2023 15:33:39 -0700 (PDT) On Tue, Oct 24, 2023 at 6:56=E2=80=AFAM 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. > > Note: I am okay for both approach, if someone can help to ensure that > all architectures do not need the tlb flush when clearing the accessed > bit, then I also think Barry's patch is better (hope Barry can resend > his patch). > > [1] https://lore.kernel.org/lkml/20220617070555.344368-1-21cnbao@gmail.co= m/ > Signed-off-by: Baolin Wang +Minchan Kim Minchan and I discussed this (again) yesterday -- I'm in favor and he can voice his different opinion on this.