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 14F64C54EE9 for ; Thu, 22 Sep 2022 03:47:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3483A6B0074; Wed, 21 Sep 2022 23:47:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F7736B0075; Wed, 21 Sep 2022 23:47:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E73D6B0078; Wed, 21 Sep 2022 23:47:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0E6386B0074 for ; Wed, 21 Sep 2022 23:47:50 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D41DE14089B for ; Thu, 22 Sep 2022 03:47:49 +0000 (UTC) X-FDA: 79938337458.07.FA52897 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf22.hostedemail.com (Postfix) with ESMTP id 1382EC0005 for ; Thu, 22 Sep 2022 03:47:47 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VQQi8tk_1663818461; Received: from 30.240.98.118(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VQQi8tk_1663818461) by smtp.aliyun-inc.com; Thu, 22 Sep 2022 11:47:42 +0800 Message-ID: <4117f7f5-8156-d8c7-9e48-55a1b632f83d@linux.alibaba.com> Date: Thu, 22 Sep 2022 11:47:41 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [RFC 0/6] migrate_pages(): batch TLB flushing To: Zi Yan , Huang Ying Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Yang Shi , Baolin Wang , Oscar Salvador , Matthew Wilcox References: <20220921060616.73086-1-ying.huang@intel.com> From: haoxin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663818469; a=rsa-sha256; cv=none; b=nBNpbWGGC70hSYTiYzaLkn8WDDDrtT//jrKcWsa1L7pfqxfoSryiJ+CitWjRqo/mWjP2vO SueaKFeA7dP4/Sy0n5uEsV7kxXrje7pOV0FnKw+nwHgRI6I3oJ0pZdYCui+L3ttvdhPJfg mPnOsunXlpKAyytLT/C1Ta7MLOTWp/M= 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 xhao@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663818469; 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=fBeOvMYs2uijIji/2BQLsAzdJKjm7+At1s/XZulDKHY=; b=HwB+nLqKI6egn/5RuicIwbC2XzPl86iOaE5UOUJll0D26YmyAM4rr7Eo+vrwF4KGvGfHTn 4tRQT2DSzuSO/aQWY9e3+lhiaWvCltK7M6oR06/6AGnq5lBxxNQPd9gSCx33fzGcd01svL 5jNREJyYLX0Uj8d7Q15l7vfnxx/ELGo= X-Stat-Signature: 5cnc7z3gferbogt4d9rhjmsf1hpfmnjt X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf22.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com X-Rspamd-Queue-Id: 1382EC0005 X-Rspamd-Server: rspam04 X-HE-Tag: 1663818467-785463 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: 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. 在 2022/9/21 下午11:47, Zi Yan 写道: > 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