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 8ED30C32771 for ; Wed, 28 Sep 2022 03:33:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B08C08E011C; Tue, 27 Sep 2022 23:33:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB88E8E00C1; Tue, 27 Sep 2022 23:33:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 980268E011C; Tue, 27 Sep 2022 23:33:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 88DDE8E00C1 for ; Tue, 27 Sep 2022 23:33:21 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5F58081110 for ; Wed, 28 Sep 2022 03:33:21 +0000 (UTC) X-FDA: 79960073802.16.9CFA9C7 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf18.hostedemail.com (Postfix) with ESMTP id 80E431C000A for ; Wed, 28 Sep 2022 03:33:19 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R951e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VQuAZVs_1664335994; Received: from 30.240.98.9(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VQuAZVs_1664335994) by smtp.aliyun-inc.com; Wed, 28 Sep 2022 11:33:16 +0800 Message-ID: <02e9da8a-39af-f6bd-b7f3-c60b3f2a59fb@linux.alibaba.com> Date: Wed, 28 Sep 2022 11:33:13 +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: "Huang, Ying" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Zi Yan , Yang Shi , Baolin Wang , Oscar Salvador , Matthew Wilcox , yangyicong@hisilicon.com, v-songbaohua@oppo.com, 21cnbao@gmail.com References: <20220921060616.73086-1-ying.huang@intel.com> <393d6318-aa38-01ed-6ad8-f9eac89bf0fc@linux.alibaba.com> <874jws2r6o.fsf@yhuang6-desk2.ccr.corp.intel.com> From: haoxin In-Reply-To: <874jws2r6o.fsf@yhuang6-desk2.ccr.corp.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664336001; a=rsa-sha256; cv=none; b=493eQ0ACTB9hSZAWJSfkD/+NCofAqpcZEJCmspaOSfRkKZYi4WbwgHuHya3sg/peaSUPsB O6XqMgH66Ch/QAr4t50e11Hb0VeSsf4syAMUQDr3iTp66MNa1tN0pT5QW3He18UfmZbqAU 36TzPrx5WE9WCiAmf/43IgU9dQLxKlg= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664336001; 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=THPvJAr6NekxzX0k1NpaThPTvQGKGKK0uyXQROz85I4=; b=XdB6EuWC/F46fyiMZmtBDEWzXZf58eUhbcNuuvTxOhFD/oWb8MELqMMtyo1Gn2sePhJlP8 BogzltWAz3ZaFfpqzV8mcjht6YIMP3K2TiN0P6Ox861DFGAWnI6Qv3Wud8kgnVx2nbCiPZ ZbSDrugAvYRXVd+uvFH3wzY/xL0Ti7E= X-Rspamd-Server: rspam10 X-Rspam-User: Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Stat-Signature: g9m3m535mgz5n9sx16rw5t1mnpngcwn3 X-Rspamd-Queue-Id: 80E431C000A X-HE-Tag: 1664335999-141043 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: 在 2022/9/28 上午10:01, Huang, Ying 写道: > 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. Oh, yes, i  ignore this, thank you. > >> 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. Next time,  i will combine with this patch, and do some test again, do you have any suggestion about  benchmark ? > > Best Regards, > Huang, Ying