Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7678850rwp; Tue, 18 Jul 2023 21:05:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlFClKfYmMQMQQpBLCNsv6h4F53KjjgejDFPKNoMv3o5arwI3qjwXcNi/P/VzkhpDk0capRz X-Received: by 2002:a17:906:74cc:b0:994:673:8afe with SMTP id z12-20020a17090674cc00b0099406738afemr1290069ejl.27.1689739538870; Tue, 18 Jul 2023 21:05:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689739538; cv=none; d=google.com; s=arc-20160816; b=Vpp4uDh37zfia7CYWkVvPKG4OCENjYYMBuWm9A2B9FY/HyJSCztcx6VZ1+ZojrvAzc i3Mqx0cKAvsd1CgjBaNLcATsJ1/1LKmW6/T5GQjQPAP0fsrcHJN7WIsLyfQ6iAHcTlOX NN+/C/Yhkkl0pZYThF863BqvE6rFL6cS/B8p5YlyxKhocCz0uW7Gt8XBlcx8pglq001Z UjfuQ0Cg9NtzDjxTOCCXLgaRJrs5z1k5S46yY7phnrPaP6c7NkeoX0awUN96k95iCBpz rznN5j33P6IsMIUmUKYNK0FsGH/6OV5Be0S2ykN12BOqK/oWyLlkBz7elZIEfe4I7PWh peXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=9/bKdSl4bL/ALz46t3piE5f2eCd5ENeQ8V1dbQqCg9c=; fh=li3DYAg9f+WJbDDzsXhhaKqSJA7hxW+E0stO3ZjuZok=; b=NC6N/R+bv+XvPa6ZLAuxFkDfnWzw0h8ZIGD0DNP4kEFRnFaqA8elJqhS09mOzqfQZu rJHbgHxtm0iO8sy/rTmeSMwBhcueHF0B10jX4oA3Hl8qasPf3Mi6gz075E3Ngui7N8xY xDN4T5R4xpEK4jC9EK+11UjlH6WdxUg6CbKnfqyCiebqjF7EnhBLoMOO8+hBYeB5ECag E0naXLv898nQdHlrAoFmVqSZ/zkRifkJzVXamFTrAvH7V0WodhG9p27l3wodrsHQTrF+ q3F5VoEQ+JR+WDRfpw/RRT6+T4AbbxvWJvj3rvMizx20s8ZS8+yViDI9glgBy21yX0kr KL0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=qTMC2PfZ; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g18-20020a170906395200b0098dea0a1eb4si2084479eje.700.2023.07.18.21.05.01; Tue, 18 Jul 2023 21:05:38 -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=@linux.dev header.s=key1 header.b=qTMC2PfZ; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229513AbjGSDgg (ORCPT + 99 others); Tue, 18 Jul 2023 23:36:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjGSDge (ORCPT ); Tue, 18 Jul 2023 23:36:34 -0400 Received: from out-17.mta1.migadu.com (out-17.mta1.migadu.com [IPv6:2001:41d0:203:375::11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CD06A4 for ; Tue, 18 Jul 2023 20:36:33 -0700 (PDT) Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1689737791; h=from:from: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=9/bKdSl4bL/ALz46t3piE5f2eCd5ENeQ8V1dbQqCg9c=; b=qTMC2PfZJIX6ph5q/BQMb7swLil9bXc6mnr4B99vRzZ+6MFfqW+rxOLWHjdtrzlwUfXsUK u6s5XHVNbse7WX/9Fprhd6EKbW3t+64IhHP43mIWQyzpXJ/7ytTKH4pUA362YCrmmN8a89 qtXXBcLfZjBeb5AXF7KfaIN25KCsbc4= MIME-Version: 1.0 Subject: Re: [PATCH v2 2/2] hugetlb: optimize update_and_free_pages_bulk to avoid lock cycles X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20230718004942.113174-3-mike.kravetz@oracle.com> Date: Wed, 19 Jul 2023 11:35:44 +0800 Cc: Linux Memory Management List , LKML , Jiaqi Yan , Naoya Horiguchi , Muchun Song , Miaohe Lin , Axel Rasmussen , James Houghton , Michal Hocko , Andrew Morton Content-Transfer-Encoding: 7bit Message-Id: References: <20230718004942.113174-1-mike.kravetz@oracle.com> <20230718004942.113174-3-mike.kravetz@oracle.com> To: Mike Kravetz X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,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 > On Jul 18, 2023, at 08:49, Mike Kravetz wrote: > > update_and_free_pages_bulk is designed to free a list of hugetlb pages > back to their associated lower level allocators. This may require > allocating vmemmmap pages associated with each hugetlb page. The > hugetlb page destructor must be changed before pages are freed to lower > level allocators. However, the destructor must be changed under the > hugetlb lock. This means there is potentially one lock cycle per page. > > Minimize the number of lock cycles in update_and_free_pages_bulk by: > 1) allocating necessary vmemmap for all hugetlb pages on the list > 2) take hugetlb lock and clear destructor for all pages on the list > 3) free all pages on list back to low level allocators > > Signed-off-by: Mike Kravetz Reviewed-by: Muchun Song Thanks.