Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp716094lqe; Sat, 6 Apr 2024 23:58:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV0E3A5uEhLSFrtJO+Ux5I51VaHBo7wFZZyuOEMSIjD8s2EiYPxaYHYZKzuEeRUU8bvn/9FqGm3C7WlLJExVF2+4vMg2p6cKuvvx75mPA== X-Google-Smtp-Source: AGHT+IGf5Id0A0rE+WiUINMp9KngOd9oaS0BOztwtGUz+b2U/ahYZcM65nvwpBUiIYWCYO+nGav3 X-Received: by 2002:a17:907:7e8e:b0:a51:b008:dc62 with SMTP id qb14-20020a1709077e8e00b00a51b008dc62mr3513935ejc.59.1712473102702; Sat, 06 Apr 2024 23:58:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712473102; cv=pass; d=google.com; s=arc-20160816; b=TgxNtxRSe9ks+qT2vCWGLGhxNmx5nuJamsBGFyW8Dxkoh/Rgg054R5QzlBXpTmuk4u vd+eMdD4S0gaJASSbsi6hp1nCpgR3g0jQEJAJAHGM5uw09z0qmH/0Ns46ClSDgHurnpp vuc+kVTXtbkxNUqcmU5Zs4Py3+PhzPBw4/5zub1H/O48CA0JVu5xrD/kQ87gJPMi5hb3 iXtSAv6yE2INFyNHx7zvxhiQG+JPu8S4zbAN7LnxhuthXM9MDyadQFKVt+esOHCzJZ7C ZjHmDLimJutVxplqMXJaSpOAkyBRagbzQB33BjdUShm3OwxMNA5j1YAroW1wY3Yswlno w7pA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=keZgjnQ9O+2hNdJMQ6VR91QK3KYWM4wdrpBYXw8no5M=; fh=jMfQ/9atpuwV3XmXGRy8WrWZ02z8skeLIQ+xfldG+Jk=; b=ASzDT1lSYyEJ41CyLsqKOgPWhh2ZQDdXaLJsw6E2fAa1UkIvRBhUrefpnFdpUvb9N7 o5vu2zHxD9xnNSdJROMuQtmNvc1bWJeedbQ0LdS0qOia6S3SBrx5CrMUSSrkLNHS1Pf7 OnfYp/THKQaJAoNsUmFC9bsx9HbCcq+Zpq3P5WmIJc/sjgbLOTz/uwBjrhtRMEyugYm8 L2trmSTKP/yjBhFvWR9wYdbzBj8i9IeLqBVJzNO63q1cpezv8guuNp2XEoXxGno8Y6LV 1AKUIBeXqRB/ip3BNhpiv/KwEgK2O6Y3raQkf4sgESkCpCEAX4TVfynMWa5i94n8KjWf rniw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=RvIQ7f5j; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-134208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134208-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id fx24-20020a170906b75800b00a51bc4ba7absi1291217ejb.1052.2024.04.06.23.58.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 23:58:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=RvIQ7f5j; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-134208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134208-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 707FE1F22C74 for ; Sun, 7 Apr 2024 06:58:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5EE0579D1; Sun, 7 Apr 2024 06:58:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="RvIQ7f5j" Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA8B87489 for ; Sun, 7 Apr 2024 06:58:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712473098; cv=none; b=rLDc5VW/DI2V+bFILy/dBUimvACkFdgFSNWkSJSJPvy2gPZqH1jp2+sFddCa0fzhuyaLIDTCfc3Dwm82m/kQY5dCCqx0H/teOf11/boVvrnahFEqWPBD39ABg+pv/75Bis7+i+M80FS4Ws+R87scG6I+wPkfJaodtFsAo5r7m7s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712473098; c=relaxed/simple; bh=TaNgPEqiKGl7DzwBOZcUc0XNLqFsrIeNAGpIOO0BTsU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=cO5Cm73OfvtYDsumDMukGEbKahzpEh8ERfmJ2K5V/8M/706qy+DUWY3uZiKOG+6kNl3x/36NyjSSHx0TCGk3/kGXG4niaPLUeuVwoPx3oBxg58MI9jB3ML901qGZ4rVg81RloIuYQIBbDJDt1unvwcEFSL/zqaTcumB1CMnctcE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=RvIQ7f5j; arc=none smtp.client-ip=115.124.30.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1712473092; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=keZgjnQ9O+2hNdJMQ6VR91QK3KYWM4wdrpBYXw8no5M=; b=RvIQ7f5jjaSlelrNYF2fvq7zaKGNkyuIlQrzyMvElTxnhuFUvWLb3uoqW9f5gyT7SwUidH5ExOvcqOoQDDVzlFbBnXwSrdBE8DwT/M7iua1lmp8SBv66Ci0OgaCDoP8do9M8UhAnEd6QTSl6OWh7hPqr5dWukFFE2L683POmiVs= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R681e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0W4.dlUx_1712473012; Received: from 30.97.56.66(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W4.dlUx_1712473012) by smtp.aliyun-inc.com; Sun, 07 Apr 2024 14:58:12 +0800 Message-ID: Date: Sun, 7 Apr 2024 14:58:11 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 06/10] mm: page_alloc: fix freelist movement during block conversion To: Johannes Weiner Cc: Andrew Morton , Vlastimil Babka , Mel Gorman , Zi Yan , "Huang, Ying" , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240320180429.678181-1-hannes@cmpxchg.org> <20240320180429.678181-7-hannes@cmpxchg.org> <20240405165632.GA870124@cmpxchg.org> From: Baolin Wang In-Reply-To: <20240405165632.GA870124@cmpxchg.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/4/6 00:56, Johannes Weiner wrote: > Hi Baolin, > > On Fri, Apr 05, 2024 at 08:11:47PM +0800, Baolin Wang wrote: >> On 2024/3/21 02:02, Johannes Weiner wrote: >>> @@ -2127,15 +2165,14 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype, >>> return page; >>> } >>> } >>> -retry: >>> + >>> page = __rmqueue_smallest(zone, order, migratetype); >>> if (unlikely(!page)) { >>> if (alloc_flags & ALLOC_CMA) >>> page = __rmqueue_cma_fallback(zone, order); >>> - >>> - if (!page && __rmqueue_fallback(zone, order, migratetype, >>> - alloc_flags)) >>> - goto retry; >>> + else >>> + page = __rmqueue_fallback(zone, order, migratetype, >>> + alloc_flags); >> >> (Sorry for chim in late.) >> >> I have some doubts about the changes here. The original code logic was >> that if the 'migratetype' type allocation is failed, it would first try >> CMA page allocation and then attempt to fallback to other migratetype >> allocations. Now it has been changed so that if CMA allocation fails, it >> will directly return. This change has caused a regression when I running >> the thpcompact benchmark, resulting in a significant reduction in the >> percentage of THPs like below: >> >> thpcompact Percentage Faults Huge >> K6.9-rc2 K6.9-rc2 + this patch >> Percentage huge-1 78.18 ( 0.00%) 42.49 ( -45.65%) >> Percentage huge-3 86.70 ( 0.00%) 35.13 ( -59.49%) >> Percentage huge-5 90.26 ( 0.00%) 52.35 ( -42.00%) >> Percentage huge-7 92.34 ( 0.00%) 31.84 ( -65.52%) >> Percentage huge-12 91.18 ( 0.00%) 45.85 ( -49.72%) >> Percentage huge-18 89.00 ( 0.00%) 29.18 ( -67.22%) >> Percentage huge-24 90.52 ( 0.00%) 46.68 ( -48.43%) >> Percentage huge-30 94.44 ( 0.00%) 38.35 ( -59.39%) >> Percentage huge-32 93.09 ( 0.00%) 39.37 ( -57.70%) > > Ouch, sorry about that! I changed that specific part around later > during development and didn't retest with CMA. I'll be sure to > re-enable it again in my config. > >> After making the following modifications, the regression is gone. >> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >> index ce67dc6777fa..a7cfe65e45c1 100644 >> --- a/mm/page_alloc.c >> +++ b/mm/page_alloc.c >> @@ -2139,7 +2139,8 @@ __rmqueue(struct zone *zone, unsigned int order, >> int migratetype, >> if (unlikely(!page)) { >> if (alloc_flags & ALLOC_CMA) >> page = __rmqueue_cma_fallback(zone, order); >> - else >> + >> + if (!page) >> page = __rmqueue_fallback(zone, order, migratetype, >> alloc_flags); >> } >> >> But I am not sure your original change is intentional? IIUC, we still >> need try fallbacking even though CMA allocation is failed, please >> correct me if I misunderstand your code. Thanks. > > No, this was accidental. I missed that CMA dependency when changing > things around for the new return type of __rmqueue_fallback(). Your > fix is good: just because the request qualifies for CMA doesn't mean > it will succeed from that region. We need the fallback for those. OK. Thanks for the clarification. > Andrew, could you please pick up Baolin's change for this patch? > > [baolin.wang@linux.alibaba.com: fix allocation failures with CONFIG_CMA] > > Thanks for debugging this and the fix, Baolin. My pleasure.