Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp337684rwn; Thu, 8 Sep 2022 02:21:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR4SrmgzeEeMsXzRpgQNQyML95PPnaD1u+dRcF4rFJSGSjaYprarKpmLvoKkbZEX17OXFm4D X-Received: by 2002:a17:90a:2e0c:b0:1fd:ad5a:21d1 with SMTP id q12-20020a17090a2e0c00b001fdad5a21d1mr3272660pjd.132.1662628875687; Thu, 08 Sep 2022 02:21:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662628875; cv=none; d=google.com; s=arc-20160816; b=Wp2KmK5huXHRiGKiDiUUJoiPqihDMgESkic2MrI6KNLACyHfCtrrN/oQhwgmOSn9mw pOczWYDeWcv1nHhs22o6R9OzWiHKTtJpTMn6lp3DuBwYHhgqP96BWPdzVgz+ZUOKKZSa Jidi1YUewYu93/UiEb+hoyDkqUP7HfxrGt4EnFn6VJADIYi5CIPMDyn6vl1ucrH8c4g7 CmIV7r9T7B0Qdj5uHDO/l2zMZYObMD+bPK4x9g+hVI5f9AYZHTcED7ffKA4TAywat1UE X4+I1IL6HtWNtWrYc+Sb9ccLnF8MMLim+NpjYoW7W8lzQhqZ2Znu/2x6l3nLZWArABtA hZvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=nzJzA+nxMXxeNwoxnxg+5h3VujvYaJ9k0ViLz+0cTqM=; b=tm9RLqeEklksgwqgzoAz0zbUxt3PWEfjS1XDdJAKChs65LO/l2UtyEwV9sB45loJy4 UgFh2LFo1zjWUrMrhXnVPtRHiWeL7ZCFUAGRnGyQmg67XbTtQjHoAY/NVpxWgNBm5s66 G0nqHNLkvKp/6de+u0I0ntM0KIueivVEDHDhsE0b6zlMHCjwSPlGHnXHKWo2RymIA8ra uTVnxwXdmgTFcGUrORQFZ41HoRa5eCK3g1bhEJIMrnuC+tCyBLKM9NYoBfMzGIO51XsZ R/JN9AZmyHZ6ubaU882fddsncgL4nj41t6bKsAxsGnGU7OIZuVbRRFgA0YgnYsWy0Arb 3S2w== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a63750f000000b00429bf9c39c0si18781557pgc.255.2022.09.08.02.21.04; Thu, 08 Sep 2022 02:21:15 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231144AbiIHIk0 (ORCPT + 99 others); Thu, 8 Sep 2022 04:40:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231347AbiIHIkU (ORCPT ); Thu, 8 Sep 2022 04:40:20 -0400 Received: from outbound-smtp44.blacknight.com (outbound-smtp44.blacknight.com [46.22.136.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E06FC9859A for ; Thu, 8 Sep 2022 01:40:17 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp44.blacknight.com (Postfix) with ESMTPS id 5918CF81DB for ; Thu, 8 Sep 2022 09:40:16 +0100 (IST) Received: (qmail 21798 invoked from network); 8 Sep 2022 08:40:16 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.198.246]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 8 Sep 2022 08:40:16 -0000 Date: Thu, 8 Sep 2022 09:40:08 +0100 From: Mel Gorman To: Zhenhua Huang Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Joonsoo Kim Subject: Re: [PATCH] mm/page_owner.c: remove redudant drain_all_pages Message-ID: <20220908084008.tmerssqksyrg3knl@techsingularity.net> References: <1662537673-9392-1-git-send-email-quic_zhenhuah@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1662537673-9392-1-git-send-email-quic_zhenhuah@quicinc.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,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 On Wed, Sep 07, 2022 at 04:01:13PM +0800, Zhenhua Huang wrote: > Page owner info of pages in pcp list have already been reset: > free_unref_page > -> free_unref_page_prepare > -> free_pcp_prepare > -> free_pages_prepare which do page owner > reset > -> free_unref_page_commit which add pages into pcp list > It can also be confirmed from dump that page owner info of pcp pages are > correct. Hence there is no more need to drain when reading. > > Signed-off-by: Zhenhua Huang This is subtle because there is no comment explaining why drain_all_pages is called and git history does not help. I agree that the page owner information has already been reset and has been since the very beginning but I do not think that is *why* drain_all_pages is called here. After the drain_all_pages, there is a fairly standard PFN walker with this in it; /* Find an allocated page */ for (; pfn < max_pfn; pfn++) { .... page = pfn_to_page(pfn); if (PageBuddy(page)) { unsigned long freepage_order = buddy_order_unsafe(page); if (freepage_order < MAX_ORDER) pfn += (1UL << freepage_order) - 1; continue; } .... } The PFN walker is trying to skip free pages efficiently and PCP pages are not buddy pages so the order is unknown. The order *can* be known but it's risky to try detecting it. I suspect the drain_all_pages is called to move PCP pages to the buddy list so they can identified as buddy pages and skipped and has nothing to do with resetting the page owner. If that is correct then I think it is overkill to drain the PCP lists to marginally improve the efficiency of the PFN walker and the drain is subject to a race. Just because the PCP lists are drained does not mean a new PCP page will be added during the PFN walk. Furthermore, PCP pages get skipped because PAGE_EXT_OWNER_ALLOCATED is cleared so it's not about scan safety. The drain is a guaranteed expensive operation that is unlikely to be offset by a slight increase in efficiently of the PFN walker when skipping free pages so the drain_all_pages should be dropped. I believe the patch itself is correct but the changelog needs to be changed. With a changelog stating that the patch is removing an expensive and unnecessary operation as PCP pages are safely skipped; Acked-by: Mel Gorman But just in case -- Joonsoo, can you clarify why drain_all_pages was originally called? -- Mel Gorman SUSE Labs