Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1195375rwo; Wed, 2 Aug 2023 10:03:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlFtDmqBdwgBfeO9Rbf5PbbVPW2tILyF5GmwRnPYRHw8uTCVVQLSqgeB5DUQ3EFIYYxIYFee X-Received: by 2002:a05:6a00:9a6:b0:687:404f:4d5a with SMTP id u38-20020a056a0009a600b00687404f4d5amr10798711pfg.13.1690995817233; Wed, 02 Aug 2023 10:03:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690995817; cv=none; d=google.com; s=arc-20160816; b=N+uRVF1+wOc/OO+woomrwoLAj6buCnqZb9bSo+/0Lw+WnszrXTWmWLdrh2uBeHoenq BaGNeg1MVLZqD5tivApt+d8+GmLIaaqGofwRJMW6dWga9MSyrmRiAB06MwkMQUyptcMA fkOB5KnLeXqtj3ChIptGU50ullvN++xxnE3ach4NHq8x9QyTtOvM4Eg5sgVw7Gq0/NA5 wxrVnudylNn2EQOJR7pBPBVd7EE+NWlITpaDdBCLDMXt8mX+GYdRxoKQXdtEe3zTN88g 1QMX40RTEWcU7Fup6JI2liAIFqIiYGYyIckysSjx90LSk8E5SkWMTmwXlMiJhcdMU1rJ rpnA== 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=jhKfbd/nBXMyknRSTtv5Kgnog2uFLjt/H6KBgEvMZo0=; fh=HAzKAPzf+ttKigYSHRTrP0Csz3PEGnBRyMw68mb5ZBA=; b=kgiqtKTPg2s6OFqfmiNseVvGPRy37Y9uU+9Yz1QhKF8lbM43Xcic4FWjteqobRSVii RoxjuzQ90XfiVUO5M1Ut6hcbxkTdKzthKhScd3Su8PbR2B/mC0vB3MmUk90INiWhMQwL bX99pbWBh4vFJkgrh/IC5Y8fQzt9LzgIoaQyy7wfnzXjustUQ8Nx9hfP8HZeD9JMeIfK IW9CwtNO3uBB6GX5Dghde/fqxWg7QYtDD3uKC/LYyCyzaG2KYPL3vceZOKTHjkwfqyuH Jq0PwwK5KJPDaNG+zbQ+ngAotk1fUbwaGNjZA+1s3tE3WRWE1V31wu7UDjZz6mYmP5D1 Pf3g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s1-20020a63dc01000000b0056427788d80si8109844pgg.653.2023.08.02.10.03.23; Wed, 02 Aug 2023 10:03:37 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229717AbjHBQmb (ORCPT + 99 others); Wed, 2 Aug 2023 12:42:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbjHBQma (ORCPT ); Wed, 2 Aug 2023 12:42:30 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9CF21269A for ; Wed, 2 Aug 2023 09:42:27 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 90C41113E; Wed, 2 Aug 2023 09:43:10 -0700 (PDT) Received: from [10.57.77.90] (unknown [10.57.77.90]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 359D63F6C4; Wed, 2 Aug 2023 09:42:25 -0700 (PDT) Message-ID: Date: Wed, 2 Aug 2023 17:42:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v4 0/3] Optimize large folio interaction with deferred split To: Andrew Morton , Matthew Wilcox , Yin Fengwei , David Hildenbrand , Yu Zhao , Yang Shi , "Huang, Ying" , Zi Yan , Nathan Chancellor , Alexander Gordeev , Gerald Schaefer , "Kirill A. Shutemov" Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20230727141837.3386072-1-ryan.roberts@arm.com> From: Ryan Roberts In-Reply-To: <20230727141837.3386072-1-ryan.roberts@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 Hi Andrew, After discussion about this in Matthew's THP Cabal, we have decided to take a different approach with this patch set. Could you therefore remove it from mm-unstable, please? Sorry about the noise. I'm going to try 2 different approaches: - avoid the split lock contention by using mmu gather (suggested by Kirill) - expand the zap pte batching to also cover file folios (as requested by Yu). Thanks, Ryan On 27/07/2023 15:18, Ryan Roberts wrote: > Hi All, > > This is v4 of a small series in support of my work to enable the use of large > folios for anonymous memory (known as "FLEXIBLE_THP" or "LARGE_ANON_FOLIO") [5]. > It first makes it possible to add large, non-pmd-mappable folios to the deferred > split queue. Then it modifies zap_pte_range() to batch-remove spans of > physically contiguous pages from the rmap, which means that in the common case, > we elide the need to ever put the folio on the deferred split queue, thus > reducing lock contention and improving performance. > > This becomes more visible once we have lots of large anonymous folios in the > system, and Huang Ying has suggested solving this needs to be a prerequisit for > merging the main FLEXIBLE_THP/LARGE_ANON_FOLIO work. > > The series applies on top of v6.5-rc3 and a branch is available at [4]. > > NOTE: v3 is currently in mm-unstable and has a bug that affects s390, which this > version fixes. > > > Changes since v3 [3] > -------------------- > > - Fixed bug reported on s390 [6] > - Since s390 enables MMU_GATHER_NO_GATHER, __tlb_remove_page() causes a ref > to be dropped on the page, but we were still using the page after that > function call. > - Fix by using folio_get()/folio_put() to guarrantee lifetime of page > - Thanks to Nathan Chancellor for the bug report and helping me get set up > with s390! > - Don't use batch path if folio is not large > > > Changes since v2 [2] > -------------------- > > - patch 2: Reworked at Yu Zhou's request to reduce duplicated code. > - page_remove_rmap() now forwards to folio_remove_rmap_range() for the > !compound (PMD mapped) case. > - Both page_remove_rmap() and folio_remove_rmap_range() share common > epilogue via new helper function __remove_rmap_finish(). > - As a result of the changes, I've removed the previous Reviewed-bys. > - other 2 patches are unchanged. > > > Changes since v1 [1] > -------------------- > > - patch 2: Modified doc comment for folio_remove_rmap_range() > - patch 2: Hoisted _nr_pages_mapped manipulation out of page loop so its now > modified once per folio_remove_rmap_range() call. > - patch 2: Added check that page range is fully contained by folio in > folio_remove_rmap_range() > - patch 2: Fixed some nits raised by Huang, Ying for folio_remove_rmap_range() > - patch 3: Support batch-zap of all anon pages, not just those in anon vmas > - patch 3: Renamed various functions to make their use clear > - patch 3: Various minor refactoring/cleanups > - Added Reviewed-By tags - thanks! > > > [1] https://lore.kernel.org/linux-mm/20230717143110.260162-1-ryan.roberts@arm.com/ > [2] https://lore.kernel.org/linux-mm/20230719135450.545227-1-ryan.roberts@arm.com/ > [3] https://lore.kernel.org/linux-mm/20230720112955.643283-1-ryan.roberts@arm.com/ > [4] https://gitlab.arm.com/linux-arm/linux-rr/-/tree/features/granule_perf/deferredsplit-lkml_v4 > [5] https://lore.kernel.org/linux-mm/20230714160407.4142030-1-ryan.roberts@arm.com/ > [6] https://lore.kernel.org/linux-mm/20230726161942.GA1123863@dev-arch.thelio-3990X/ > > Thanks, > Ryan > > > Ryan Roberts (3): > mm: Allow deferred splitting of arbitrary large anon folios > mm: Implement folio_remove_rmap_range() > mm: Batch-zap large anonymous folio PTE mappings > > include/linux/rmap.h | 2 + > mm/memory.c | 132 +++++++++++++++++++++++++++++++++++++++++++ > mm/rmap.c | 125 ++++++++++++++++++++++++++++++---------- > 3 files changed, 229 insertions(+), 30 deletions(-) > > -- > 2.25.1 >