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 0F440C07E9D for ; Wed, 28 Sep 2022 02:01:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9883D8E0113; Tue, 27 Sep 2022 22:01:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9380E8E00C1; Tue, 27 Sep 2022 22:01:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7FEFB8E0113; Tue, 27 Sep 2022 22:01:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6F2348E00C1 for ; Tue, 27 Sep 2022 22:01:42 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 45612A1062 for ; Wed, 28 Sep 2022 02:01:42 +0000 (UTC) X-FDA: 79959842844.12.3999242 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf30.hostedemail.com (Postfix) with ESMTP id 89EFE8000B for ; Wed, 28 Sep 2022 02:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664330501; x=1695866501; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=mIDSfyD4C874NNhP2JbYFUb/z54En2t5heGm3o3CQLA=; b=l1kPMIhYiSFwCCAF/Inc7GxcuCkUMz9CErWvzSE1jWSKlhztrDLawGIM bwSxr5ImrMnYkqj6CZ8e+aQsTd+b/Mp6CJ9OfpXvC2tSAPpKpkjnWbNRK s2QNzsOvudmnobu2kps/BQ9Cz7XjwIu7b3KflWjky4r3Jf8jUB0G/I8ll pS4AHA8u3e51TX4/yAK+SY+zE09wvLD26G1VJAEMAprkrTRoB/lr4wwon AD3SSTwojhKFElPujIgYmXTRQsq48Ga1xy0An3YuWtPQPE19Gc2YUlPs+ x9lahuPsIkOWw7axXICnD5QDPyWsP+TDvUatf2vTGMsD0V8QQiOWvoZH6 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="284611458" X-IronPort-AV: E=Sophos;i="5.93,350,1654585200"; d="scan'208";a="284611458" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 19:01:40 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="764096492" X-IronPort-AV: E=Sophos;i="5.93,350,1654585200"; d="scan'208";a="764096492" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 19:01:37 -0700 From: "Huang, Ying" To: haoxin Cc: , , Andrew Morton , Zi Yan , Yang Shi , Baolin Wang , Oscar Salvador , "Matthew Wilcox" , , , <21cnbao@gmail.com> Subject: Re: [RFC 0/6] migrate_pages(): batch TLB flushing References: <20220921060616.73086-1-ying.huang@intel.com> <393d6318-aa38-01ed-6ad8-f9eac89bf0fc@linux.alibaba.com> Date: Wed, 28 Sep 2022 10:01:03 +0800 In-Reply-To: <393d6318-aa38-01ed-6ad8-f9eac89bf0fc@linux.alibaba.com> (haoxin's message of "Tue, 27 Sep 2022 19:21:08 +0800") Message-ID: <874jws2r6o.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664330501; a=rsa-sha256; cv=none; b=CGSAka3TolPPtA+hKDFUhy+fxjYJ8W9Spwc8ogebyXLXHPRdl+ZahwbhEgKqCaMHlPWB71 1g/5OCN+CjLuIsc85gXGMfhnjzfiInKR7kfPnsocBApRyNrbu36OXiLlmR6Dr0uaPz/DZy meCJ+w1ep8oOdw/rpCaBD8MpWVfUwXo= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=l1kPMIhY; spf=pass (imf30.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664330501; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gY8NEavcrWwvFPf4Ycg/lyx5vLOjuN36QIU4z/Ii2xo=; b=hPx9bFLFs5k169pWlLFXMHmOPGvzntW44Y0O62IwBVCyQjuTIJ4O8FWsItUjYDsgVNa+KQ ojZN3KKiyq62cOSI2/W2X1wmhRl8SJfBdDB+9QsLvcZ52b/FSBlaeJFnpzul/EM1qmnDXA T+OFk80DzIB8tm1zVjBOuOw0NmBl95U= X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=l1kPMIhY; spf=pass (imf30.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspamd-Queue-Id: 89EFE8000B X-Rspamd-Server: rspam03 X-Stat-Signature: q17enrgrf8b43un8gefhtj9mnx14owm5 X-HE-Tag: 1664330501-936969 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: haoxin writes: > Hi, Huang > > ( 2022/9/21 H2:06, Huang Ying S: >> 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. >> > As the pmbench can not run on arm64 machine, so i use lmbench instead. > I test case like this: (i am not sure whether it is reasonable, but it seems worked) > ./bw_mem -N10000 10000m rd & > time migratepages pid node0 node1 > > o/patch w/patch > real 0m0.035s real 0m0.024s > user 0m0.000s user 0m0.000s > sys 0m0.035s sys 0m0.024s > > the migratepages time is reduced above 32%. > > But there has a problem, i see the batch flush is called by > migrate_pages_batch > try_to_unmap_flush > arch_tlbbatch_flush(&tlb_ubc->arch); // there batch flush really work. > > But in arm64, the arch_tlbbatch_flush are not supported, becasue it not support CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH yet. > > So, the tlb batch flush means no any flush is did, it is a empty func. Yes. And should_defer_flush() will always return false too. That is, the TLB will still be flushed, but will not be batched. > Maybe this patch can help solve this problem. > https://lore.kernel.org/linux-arm-kernel/20220921084302.43631-1-yangyicong@huawei.com/T/ Yes. This will bring TLB flush batching to ARM64. Best Regards, Huang, Ying