Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4855303rwl; Mon, 10 Apr 2023 18:40:58 -0700 (PDT) X-Google-Smtp-Source: AKy350bzwYfjEu0S5YhjwM1zT4QG8okCfhDhF1tVKyjDFsBs1fGFL6mRB5/evpIufiU+WgJ4yPiJ X-Received: by 2002:a05:6a20:bf2f:b0:d9:84d2:7a9f with SMTP id gc47-20020a056a20bf2f00b000d984d27a9fmr843276pzb.24.1681177258208; Mon, 10 Apr 2023 18:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681177258; cv=none; d=google.com; s=arc-20160816; b=zww1p0UlNlP9HI6DCS2RcyfSWDsXz1BkeeVv+Z7RzUOZaGj3ye60oWLiFMFVZqwOoO 54x/w551kL0ln7UwrUe2Sfcq1zQBdc6cl9+0RB/b9rR91UoQ9YzYj6aU0b/veeHxansS WbASh3NF3U17zutRLMg8dhQ0ClayXwi21MHDyalkqKq37L+f+lpIrN70dh0u5kWsV/4I MSyHJTs0vzw0ZWzkNGYvYB+AKnok598whoW2y5EBksxIw0rM7YBulX8+s/sgszY2f8fU HNJ0B/Ua54M9ZvfFk5Ri+SSeZNYKwHaeVvu5LMYuzHAABQgDwmiSKHpE5hUGXCrN2mUr dXog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from:dkim-signature; bh=6EjISWp5WkbC4p6O2uKuRvwjZS8MWWzDn4gyZOt9qX8=; b=tgzwzxVthNNTebdiIGCI2UiiM4DAnN0Uyp9tX4w/0+YQusumuRke+swT7Ct5rWkv5M hjiWXQLGztR+daLUwoU3txdhy0HIK4mpQNGMj34wuslPsOmkhIe3vsfPhMQlrpA22mRf AxwhdDuLYW3ajWIV/QDZWnnBg1gqsOb9H7JxvqowLh0ZVnglaz3AgODA1/uf98Lk7351 +TblxqkKqKL3cxp73rvTfN+0k1HjrgCybzm2RQJGM+GCWCARB7WsNS6xSm1mEODzeq6g GsKkVDA5zyDEYZdwpo/JHBiWu6GeDvxmeOIMzS8EbOuNL4ojx4QvTKD6NxkxnkcXlZ+6 jLow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=F1S2HHsc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 192-20020a6301c9000000b0050f53eec0adsi11835445pgb.616.2023.04.10.18.40.45; Mon, 10 Apr 2023 18:40:58 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=F1S2HHsc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230025AbjDKBci (ORCPT + 99 others); Mon, 10 Apr 2023 21:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjDKBcf (ORCPT ); Mon, 10 Apr 2023 21:32:35 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 545601718 for ; Mon, 10 Apr 2023 18:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681176754; x=1712712754; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version:content-transfer-encoding; bh=6uciC4UroIaZtzRZeYdo8iufB2WP1MTDBI57Zm/g/XA=; b=F1S2HHscI8OKegyzV+WvX/PwLnKhumU2bTJRMzi03tqa3euFZMbX63us qm+D+Fde04f6inpFNSxETSjQvsENReffHeXq46/UarxWQ0h7fQ9XDgvXB 8163NMaxpw41c57zyA9cvmEgZDwit2o9sYKu7k5b0aBmwoGoTZCdYCUBZ 1OrNIXIhtvlMd73/Xr46OSDtnKT79+A5nmcgRWaoBzCjKXtx2dfckkMD7 E5gDkJ+/W3E2GnWfMfr9lOUI1otre+Kz7gvuZ9MpvlWRzSb1NodldxMN+ Vu/8nbBZ5EAic2ykTq1GAPPDuj4QdYvc3K92DdI+3XctOT4HDdubYQLcV g==; X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="371343467" X-IronPort-AV: E=Sophos;i="5.98,335,1673942400"; d="scan'208";a="371343467" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2023 18:32:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="688434314" X-IronPort-AV: E=Sophos;i="5.98,335,1673942400"; d="scan'208";a="688434314" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2023 18:32:31 -0700 From: "Huang, Ying" To: Nadav Amit Cc: Andrew Morton , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , kernel test robot , "Mel Gorman" , Hugh Dickins , Matthew Wilcox , David Hildenbrand Subject: Re: [PATCH] mm,unmap: avoid flushing TLB in batch if PTE is inaccessible References: <20230410075224.827740-1-ying.huang@intel.com> <402A3E9D-5136-4747-91FF-C3AA2D557784@vmware.com> Date: Tue, 11 Apr 2023 09:31:25 +0800 In-Reply-To: <402A3E9D-5136-4747-91FF-C3AA2D557784@vmware.com> (Nadav Amit's message of "Mon, 10 Apr 2023 19:47:30 +0000") Message-ID: <87zg7f19xu.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Hi, Amit, Thank you very much for review! Nadav Amit writes: >> On Apr 10, 2023, at 12:52 AM, Huang Ying wrote: >>=20 >> 0Day/LKP reported a performance regression for commit >> 7e12beb8ca2a ("migrate_pages: batch flushing TLB"). In the commit, the >> TLB flushing during page migration is batched. So, in >> try_to_migrate_one(), ptep_clear_flush() is replaced with >> set_tlb_ubc_flush_pending(). In further investigation, it is found >> that the TLB flushing can be avoided in ptep_clear_flush() if the PTE >> is inaccessible. In fact, we can optimize in similar way for the >> batched TLB flushing too to improve the performance. >>=20 >> So in this patch, we check pte_accessible() before >> set_tlb_ubc_flush_pending() in try_to_unmap/migrate_one(). Tests show >> that the benchmark score of the anon-cow-rand-mt test case of >> vm-scalability test suite can improve up to 2.1% with the patch on a >> Intel server machine. The TLB flushing IPI can reduce up to 44.3%. > > LGTM. Thanks! > I know it=E2=80=99s meaningless for x86 (but perhaps ARM would use this i= nfra > too): do we need smp_mb__after_atomic() after ptep_get_and_clear() and > before pte_accessible()? Why do we need the memory barrier? IIUC, the PTL is locked, so PTE value will not be changed under us. Anything else? > In addition, if this goes into stable (based on the Fixes tag), consider > breaking it into 2 patches, when only one would be backported. The fixed commit (7e12beb8ca2a ("migrate_pages: batch flushing TLB")) is merged by v6.3-rc1. So this patch will only be backported to v6.3 and later. Is it OK? Best Regards, Huang, Ying