Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp269175rwb; Wed, 21 Sep 2022 22:07:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6l1dNZ1Zy9Delsae7PQpWm0q0xndaI3n7S6Qbx75qeTArGwfUqhkK3CDuhLAgzIdpqJtOT X-Received: by 2002:a17:907:7638:b0:76f:cad4:f176 with SMTP id jy24-20020a170907763800b0076fcad4f176mr1283683ejc.647.1663823232270; Wed, 21 Sep 2022 22:07:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663823232; cv=none; d=google.com; s=arc-20160816; b=l+i9e/Zm6ziPdXSfRDUp730zDY4lJrPjvetW2EgrMKq0tMYXom1BfgNAnGbH8C4qby RnxtCxJ5/mAPcG3Fmt8d3Gu3fTnx6lW0GhIXj24Zn7MkeuOWjR4n7lB9CebnH2RV5F1i vbEGH7UPZ00ZwnOpuyPgNJmr/+m3vOmxCrYZBFUQaw4g/wjmQLcW0llxhMFeUqGPaest IteUGO7BbRoEa8e29jot86GtJmpkUpZ7qj9HBstmMXyQqYiYB09w35znk+AKTD7a9qvj Lh6ynQZtjnvJrDPmQgzfbv+2rpEHFwzfBWRIu1t0RqV7fSc8EMPSZAS71UVNkw/2ViEZ PFag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=EyefootXn1rW5/7FtclScCwy99c9A7s+JjKcvUJbueU=; b=Z4jLqrPHRJZlFrm0JnHmRHo+wj4GsOWItd4XBCXtBq+RAzL+JEeXCJ226VDUz09FSP miowiq72dC+gkV+QxBAvvLDdL0VTqZKXS4UVblzZeb09h+amlfEDXM2zV+U3s5cHJB3O qrTGQLEJxhb8Jri0TCzeRp6bvnlniJeZEFVOnAMFi72iPhyUtGMIeEknKUKVmXAF1m6i znZa5RAhZ5xfiqzOmRSPJbgXrW9mncM2ZVbQce4kIB472dWXKpysMtmnkUSQIXwjjdzk yUT6WFoxvlblGT+uNMjoSVYZYYyXBvMzGeQI9yZoOHpw3CWh3g1p7KrGUxdqOEIsuIBT a6Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ae5zo0Q9; 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 sa27-20020a1709076d1b00b007825337afeesi838153ejc.273.2022.09.21.22.06.46; Wed, 21 Sep 2022 22:07:12 -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=ae5zo0Q9; 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 S229893AbiIVEhA (ORCPT + 99 others); Thu, 22 Sep 2022 00:37:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbiIVEg4 (ORCPT ); Thu, 22 Sep 2022 00:36:56 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEB987C74A for ; Wed, 21 Sep 2022 21:36:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663821415; x=1695357415; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=1XucKgX++zuNVJG9PPzZiYcNFHesLtT/2vAEDgaYSFU=; b=ae5zo0Q9lU8zgOzlWptkXLJjbceQvTP72kVngwMfTrmn7fkhYexgUW+Q 4TwQl5WiWDNoZJgWPfg2o1GfGNHZ7Ft+zjWfdBvbgRpi0TID983EtMH4y VpL4Xo0x46uXittsOwCTBMfBRW71Jtq6y+gTjoCP5XWvWZmEMWuBwjILn jbF30aKzyTHsz2lVIQz/W+vYB8YJdzD23m67SuwgICsC7LhALNfEp/CcH wt80hiWpxGuQ4CsZwoPbCXs2xl4Y04JihHbWU8U25qjKL5j8X56N341rt lCWaKsimsL518uwKn62gSESxhBYDdSKDU5FFCEnleY3HcV36XeAEh2Cc7 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10477"; a="361959487" X-IronPort-AV: E=Sophos;i="5.93,335,1654585200"; d="scan'208";a="361959487" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2022 21:36:55 -0700 X-IronPort-AV: E=Sophos;i="5.93,335,1654585200"; d="scan'208";a="570816471" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2022 21:36:53 -0700 From: "Huang, Ying" To: haoxin Cc: Zi Yan , , , Andrew Morton , Yang Shi , Baolin Wang , Oscar Salvador , "Matthew Wilcox" Subject: Re: [RFC 0/6] migrate_pages(): batch TLB flushing References: <20220921060616.73086-1-ying.huang@intel.com> <4117f7f5-8156-d8c7-9e48-55a1b632f83d@linux.alibaba.com> Date: Thu, 22 Sep 2022 12:36:45 +0800 In-Reply-To: <4117f7f5-8156-d8c7-9e48-55a1b632f83d@linux.alibaba.com> (haoxin's message of "Thu, 22 Sep 2022 11:47:41 +0800") Message-ID: <87tu50ja8y.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=ascii X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 haoxin writes: > Hi Huang, > > This is an exciting change, but on ARM64 machine the TLB > flushing are not through IPI, it depends on 'vale1is' > > instruction so I'm wondering if there's also a benefit on arm64, > and I'm going to test it on an ARM64 machine. We have no arm64 machine to test and I know very little about arm64. Thanks for information and testing. Best Regards, Huang, Ying > > ( 2022/9/21 H11:47, Zi Yan S: >> On 21 Sep 2022, at 2:06, Huang Ying wrote: >> >>> From: "Huang, Ying" >>> >>> Now, migrate_pages() migrate pages one by one, like the fake code as >>> follows, >>> >>> for each page >>> unmap >>> flush TLB >>> copy >>> restore map >>> >>> If multiple pages are passed to migrate_pages(), there are >>> opportunities to batch the TLB flushing and copying. That is, we can >>> change the code to something as follows, >>> >>> for each page >>> unmap >>> for each page >>> flush TLB >>> for each page >>> copy >>> for each page >>> restore map >>> >>> The total number of TLB flushing IPI can be reduced considerably. And >>> we may use some hardware accelerator such as DSA to accelerate the >>> page copying. >>> >>> So in this patch, we refactor the migrate_pages() implementation and >>> implement the TLB flushing batching. Base on this, hardware >>> accelerated page copying can be implemented. >>> >>> If too many pages are passed to migrate_pages(), in the naive batched >>> implementation, we may unmap too many pages at the same time. The >>> possibility for a task to wait for the migrated pages to be mapped >>> again increases. So the latency may be hurt. To deal with this >>> issue, the max number of pages be unmapped in batch is restricted to >>> no more than HPAGE_PMD_NR. That is, the influence is at the same >>> level of THP migration. >>> >>> We use the following test to measure the performance impact of the >>> patchset, >>> >>> On a 2-socket Intel server, >>> >>> - Run pmbench memory accessing benchmark >>> >>> - Run `migratepages` to migrate pages of pmbench between node 0 and >>> node 1 back and forth. >>> >>> With the patch, the TLB flushing IPI reduces 99.1% during the test and >>> the number of pages migrated successfully per second increases 291.7%. >> Thank you for the patchset. Batching page migration will definitely >> improve its throughput from my past experiments[1] and starting with >> TLB flushing is a good first step. >> >> BTW, what is the rationality behind the increased page migration >> success rate per second? >> >>> This patchset is based on v6.0-rc5 and the following patchset, >>> >>> [PATCH -V3 0/8] migrate_pages(): fix several bugs in error path >>> https://lore.kernel.org/lkml/20220817081408.513338-1-ying.huang@intel.com/ >>> >>> The migrate_pages() related code is converting to folio now. So this >>> patchset cannot apply recent akpm/mm-unstable branch. This patchset >>> is used to check the basic idea. If it is OK, I will rebase the >>> patchset on top of folio changes. >>> >>> Best Regards, >>> Huang, Ying >> >> [1] https://lwn.net/Articles/784925/ >> >> -- >> Best Regards, >> Yan, Zi