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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BF0EC4332F for ; Thu, 2 Nov 2023 07:10:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231893AbjKBHKp (ORCPT ); Thu, 2 Nov 2023 03:10:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjKBHKn (ORCPT ); Thu, 2 Nov 2023 03:10:43 -0400 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76CEC112 for ; Thu, 2 Nov 2023 00:10:40 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R371e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VvV7iIh_1698909035; Received: from 30.97.48.61(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VvV7iIh_1698909035) by smtp.aliyun-inc.com; Thu, 02 Nov 2023 15:10:37 +0800 Message-ID: <4978d86c-c55f-cf26-796d-237c81efeab3@linux.alibaba.com> Date: Thu, 2 Nov 2023 15:10:49 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] mm: huge_memory: batch tlb flush when splitting a pte-mapped THP To: Alistair Popple Cc: akpm@linux-foundation.org, shy828301@gmail.com, ying.huang@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <431d9fb6823036369dcb1d3b2f63732f01df21a7.1698488264.git.baolin.wang@linux.alibaba.com> <877cn22e0d.fsf@nvdebian.thelocal> From: Baolin Wang In-Reply-To: <877cn22e0d.fsf@nvdebian.thelocal> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/1/2023 2:13 PM, Alistair Popple wrote: > > Baolin Wang writes: > >> I can observe an obvious tlb flush hotpot when splitting a pte-mapped THP on > > A tlb flush hotpot does sound delicious, but I think you meant hotspot :-) Ah, yes. Hope Andrew can help to fix it :) >> my ARM64 server, and the distribution of this hotspot is as follows: >> >> - 16.85% split_huge_page_to_list >> + 7.80% down_write >> - 7.49% try_to_migrate >> - 7.48% rmap_walk_anon >> 7.23% ptep_clear_flush >> + 1.52% __split_huge_page >> >> The reason is that the split_huge_page_to_list() will build migration entries >> for each subpage of a pte-mapped Anon THP by try_to_migrate(), or unmap for >> file THP, and it will clear and tlb flush for each subpage's pte. Moreover, >> the split_huge_page_to_list() will set TTU_SPLIT_HUGE_PMD flag to ensure >> the THP is already a pte-mapped THP before splitting it to some normal pages. > > The only other user of TTU_SPLIT_HUGE_PMD is vmscan which also sets > TTU_BATCH_FLUSH so we could make the former imply the latter but that > seem dangerous given the requirement to call try_to_unmap_flush() so > best not to. > > Reviewed-by: Alistair Popple Thanks for reviewing, and also thanks to Ying and Yang.