Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp194369rdb; Thu, 2 Nov 2023 00:11:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxS4XTj1uxnRh1O2g0rl3pZwXIGyTWPSJM9UDb+jkO9z8WAHE3Sh9Z/j7NZi4epCGVtG0b X-Received: by 2002:a17:902:ecc2:b0:1cc:3bc5:d259 with SMTP id a2-20020a170902ecc200b001cc3bc5d259mr10323464plh.30.1698909097882; Thu, 02 Nov 2023 00:11:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698909097; cv=none; d=google.com; s=arc-20160816; b=LqbHL0qiL/jiawh6oavsAmAQrV5nqR3n+9l3YPNlS97f0/AcLb2AbnWpPJm/SXbe2d siMUQOuJaMBvnSfAiN3PVfvLayV1FCY22q0+Ld0Xam2sGdPwGq3OTPEPFQBLRpFRUGaY 7D4G11oM5yBbmj8OfCaJ0QlsiXKTndUg+s62G+WiX+wA7mb2/13fw18ZYO+yiwWyF7Yf PMcm3bCIUbeKfIqwxVxbZfK5t84ERwtFjkZWEhh9TF+CBsH4Jybz1DfZ5H8B0auNwaZ7 1QFYKHMHh0ZD8EJRw8rh8pwkPIfbHRGJKbhiyE+GhlEjTZfrAGJ9K/GJec/3D2p1aBVf HfOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=VcEIo7oBODt+O6o/xUY+0NQs/HRYpdqrK45BUP6hK8s=; fh=Mw6FNn9gruAChbAbiiU000OM2UN/CrtGYuB8EGwe7o8=; b=j2YzYW+iWufsNxB2ImQRDdEdbBfnfAWHri1humKRfExb/8BHAA5rtb2VzoIcwzStoy 607QUWugF+z372Ao5k74WT9JgLAn/YX0AWFPkrDN5zMY90z9MzR3++XcEKL0dX4ctnlw RC7vkDQnjYgHBYNwwnfTz033kW+H2yWdl+LFyutAXbkp0QqtJAyDi+d7umNaxm3R5OkR XhvrTuRJ3nUhh1ooNREvzGOGLQZUFTsVYOiDzo90D2E7bZ0bVZj0zftRRQmJdH6SGhq/ yo4msJURVHJQXWQ55nMjTBIxcuWchXXgS5i4qgUp0lbYEmchuu7WUiN4oxk53TFErFHG tSUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id n8-20020a170902d2c800b001b8b4330585si4854789plc.510.2023.11.02.00.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 00:11:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2992881CF400; Thu, 2 Nov 2023 00:11:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229549AbjKBHKo (ORCPT + 99 others); Thu, 2 Nov 2023 03:10:44 -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 X-Spam-Status: No, score=-4.5 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 02 Nov 2023 00:11:31 -0700 (PDT) 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.