Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp34928996rwd; Sun, 9 Jul 2023 23:28:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlFKSTwREnNkS8K6muQF9YwtPWFrTopr6uz7JOz2AzpgBpR5f1oQraGLGPR471258M5Szf64 X-Received: by 2002:a05:6512:3e03:b0:4f8:b349:6938 with SMTP id i3-20020a0565123e0300b004f8b3496938mr10427593lfv.65.1688970536482; Sun, 09 Jul 2023 23:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688970536; cv=none; d=google.com; s=arc-20160816; b=VjbeBcfBZyGUk5OqwdfBBbYjgdtk8SkbrRDlu7/b7Jf1kt86s8oDB4MwmLKUxoNd3i Sq5HN4ykm5t2jxgj+unW/7yFimN2P68bq7fFsjKtWMPa9qUb98TeDM2SGdY0xsWMSkdW eoB9xzAebHpd/pKaa7TvkQF1LtOusg4N4B6HTgWPFxG2naDOMZQzdwAu3xdUQ0/+QJOR N2jcrFu2YLhso77QXhzE2sqO7wmK+QPBL0+ZLbKzPp9SJrZiIYB1jBvtos/vGLPUg0Km Q9LKye7xqR3HDAeXmCEUnNCoGb7RyqmZGVHDQqic1xHxENi0aVWJv5jnDiYhuRoDzTuS mXVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=Fb1MRTTHH2W2YgWJJA5sYQ8fECMK1mltd+3vv47AgTc=; fh=NMmmgOdikptkv+fAVT5xP9benJqm6r8H2b98fa6Zzec=; b=ZmOEz3qWBgKY3AMqtaRcJm6SPudyfkhXMUpKjNL97SZmwqm8EQ7rabBKQkF5PTNPav foTRu3R+2w39HipSc2++PbfNw31OzNP5Rrw3ZiwxlRxQEqwokzsEDfUuwHGzAeFvaTzR Pu8j7VsWaFqB6n59Jp+oZQ0B3vzEQw/rPqif30dk3T0qY1iRSQo8dGeQjXULbw76sXM0 h1VaP5xDfN43K8DydsCjBfdUBN2KFiYkuJSHfZ7NyjdR/d8jr2EU0XVCmLqWR2k9C4XM VZoTEXpf3WFOhi+Ki15hXirHbEfdziVnMVkJ2qJ5BXXiuehjR0v1uEYG7aZ6oZPQXWqO kihQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VbnklF0Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z14-20020aa7cf8e000000b0051e0f7c1502si7812588edx.606.2023.07.09.23.28.33; Sun, 09 Jul 2023 23:28:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VbnklF0Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbjGJFjR (ORCPT + 99 others); Mon, 10 Jul 2023 01:39:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjGJFjQ (ORCPT ); Mon, 10 Jul 2023 01:39:16 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53476B3 for ; Sun, 9 Jul 2023 22:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688967555; x=1720503555; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=Ys8L0Hbye36COw2RYLz/SroMuaxGWFfQb1sQCRJw2nM=; b=VbnklF0YH6N5cAfiENU33UHWPYZd1mYJ9/Kcn7bmfCNmYMuapUywq5i3 kr37IArI4ZABCWUKrM3N9GikaljKOR3vRjINsyNsg4qlUilzAVVT8Juho G+RLtrCFVlHA9AOt0wUFNw1xsJEhf6NG0lmyOtuqI+dMaXvfF/gqoxEzv EEp7hmsbFRPNYVYffkEPx8ZtdIqYhczcbWRf08egcvxMr4d9KiM9F3mHt ozLgfn+DXCC+RhwKlyWQNu0MOeMUo0ruTDE/tkzinQj1ZaJ8UCTvkDZ8O ZfTGbDaTuOW+6PPctC7Wz7nqxc5uEEo0EDXwLFS9ds8dFqkEoQZZTN8S+ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10766"; a="366839046" X-IronPort-AV: E=Sophos;i="6.01,194,1684825200"; d="scan'208";a="366839046" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2023 22:39:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10766"; a="967312758" X-IronPort-AV: E=Sophos;i="6.01,194,1684825200"; d="scan'208";a="967312758" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2023 22:39:11 -0700 From: "Huang, Ying" To: Ryan Roberts Cc: Andrew Morton , Matthew Wilcox , "Kirill A. Shutemov" , Yin Fengwei , "David Hildenbrand" , Yu Zhao , "Catalin Marinas" , Will Deacon , "Anshuman Khandual" , Yang Shi , , , Subject: Re: [PATCH v2 2/5] mm: Allow deferred splitting of arbitrary large anon folios References: <20230703135330.1865927-1-ryan.roberts@arm.com> <20230703135330.1865927-3-ryan.roberts@arm.com> <877crcgmj1.fsf@yhuang6-desk2.ccr.corp.intel.com> <6379dd13-551e-3c73-422a-56ce40b27deb@arm.com> Date: Mon, 10 Jul 2023 13:37:24 +0800 In-Reply-To: <6379dd13-551e-3c73-422a-56ce40b27deb@arm.com> (Ryan Roberts's message of "Fri, 7 Jul 2023 10:42:26 +0100") Message-ID: <87ttucfht7.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ryan Roberts writes: > Somehow I managed to reply only to the linux-arm-kernel list on first attempt so > resending: > > On 07/07/2023 09:21, Huang, Ying wrote: >> Ryan Roberts writes: >> >>> With the introduction of large folios for anonymous memory, we would >>> like to be able to split them when they have unmapped subpages, in order >>> to free those unused pages under memory pressure. So remove the >>> artificial requirement that the large folio needed to be at least >>> PMD-sized. >>> >>> Signed-off-by: Ryan Roberts >>> Reviewed-by: Yu Zhao >>> Reviewed-by: Yin Fengwei >>> --- >>> mm/rmap.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/mm/rmap.c b/mm/rmap.c >>> index 82ef5ba363d1..bbcb2308a1c5 100644 >>> --- a/mm/rmap.c >>> +++ b/mm/rmap.c >>> @@ -1474,7 +1474,7 @@ void page_remove_rmap(struct page *page, struct vm_area_struct *vma, >>> * page of the folio is unmapped and at least one page >>> * is still mapped. >>> */ >>> - if (folio_test_pmd_mappable(folio) && folio_test_anon(folio)) >>> + if (folio_test_large(folio) && folio_test_anon(folio)) >>> if (!compound || nr < nr_pmdmapped) >>> deferred_split_folio(folio); >>> } >> >> One possible issue is that even for large folios mapped only in one >> process, in zap_pte_range(), we will always call deferred_split_folio() >> unnecessarily before freeing a large folio. > > Hi Huang, thanks for reviewing! > > I have a patch that solves this problem by determining a range of ptes covered > by a single folio and doing a "batch zap". This prevents the need to add the > folio to the deferred split queue, only to remove it again shortly afterwards. > This reduces lock contention and I can measure a performance improvement for the > kernel compilation benchmark. See [1]. > > However, I decided to remove it from this patch set on Yu Zhao's advice. We are > aiming for the minimal patch set to start with and wanted to focus people on > that. I intend to submit it separately later on. > > [1] https://lore.kernel.org/linux-mm/20230626171430.3167004-8-ryan.roberts@arm.com/ Thanks for your information! "batch zap" can solve the problem. And, I agree with Matthew's comments to fix the large folios interaction issues before merging the patches to allocate large folios as in the following email. https://lore.kernel.org/linux-mm/ZKVdUDuwNWDUCWc5@casper.infradead.org/ If so, we don't need to introduce the above problem or a large patchset. Best Regards, Huang, Ying