From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71AF3C67861 for ; Fri, 5 Apr 2024 16:56:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B9D26B0093; Fri, 5 Apr 2024 12:56:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 06A116B0095; Fri, 5 Apr 2024 12:56:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E4CA46B0096; Fri, 5 Apr 2024 12:56:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C732D6B0093 for ; Fri, 5 Apr 2024 12:56:41 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 81EEC1C149F for ; Fri, 5 Apr 2024 16:56:41 +0000 (UTC) X-FDA: 81976082202.25.08AD362 Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) by imf24.hostedemail.com (Postfix) with ESMTP id 2EE7B180010 for ; Fri, 5 Apr 2024 16:56:38 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=v4mLCrlJ; spf=pass (imf24.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.210.51 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712336199; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ohIubACEMqfpFhqHJzOrOyqb7k4hx5l2DO2JszCob+w=; b=SRuW5DsBHylEFgVYpLSoX5hjXQzu3P5HlTcy/rrEdP5/eK6sBhKAoFaHjgkjlf0SvhT5Oy HaNz2gk6wbTYnwl1TspvUvIv9qIAuDF8XOWQNeLWCfwiLnZEBzjuiMSQYNmaUyamTRWiat lZ1tiVKuoDGT501ZnE8v3ay+ygfb2gA= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=v4mLCrlJ; spf=pass (imf24.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.210.51 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712336199; a=rsa-sha256; cv=none; b=AZ9jxN6gr8g51WjX+/WhULV5otcI+NCmvczMdTuuQdkDI9YCMyTxzuYIy08QFcLYWU5vW4 MFeXedr3xLouCxzGawr6IgZ1Y/tXowwaa61scRYLG1Z/ygaNRSJEAyj/tvw4Wid6+6kcmY iGdT/CopzepAe7zedixZliZjLbI+Kt8= Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-6e673ffbd79so1425035a34.2 for ; Fri, 05 Apr 2024 09:56:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1712336198; x=1712940998; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ohIubACEMqfpFhqHJzOrOyqb7k4hx5l2DO2JszCob+w=; b=v4mLCrlJW+V7Ov9Qxya9bwDd3vmyJTVI09aMJEBEdAX+ZlEDHWtcqQJwDqmJQyCyab dWhenWiOAm9fln9M7diTUxho+R46dWimN224Pkz8BAn+b6LVpoBTnEIEVjywAghWZHAb hpUQ7zMh0HmxdLTq79ty1KuXjhDWOfEcsUykb96kvw+VMYRuDJ1QBIUso/icYCh1RN4j WA9ipR79aculyia1y4w7izKP00Jfs7JytnfPA0YBr0K7iVL9xnkDTlLVrx3QEdhg+slL d16dmWDjNxtDxhFnRxCGF/UaRqve8lFjbVASupG/W8ooSO7Cn8UO+w/TtcPB5MWRasRg 3HBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712336198; x=1712940998; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ohIubACEMqfpFhqHJzOrOyqb7k4hx5l2DO2JszCob+w=; b=fkxnySTslnPXV5L/mo9d+KCXdqckEOoOSqw0tDRB0NUkRiGYLQY+2TJ8VPRGa0+8R/ DNFX3+QJH4f11/rgBKQN85UMr9DmAtSohHsVt53yEQQWwftTRFBS9nWbMoaxE1LNEKSA 4A18Ual/Bwv8fVEYrD9S7PkgH1pM80mBzaHxZ2Pnhxow178iUQFmaGWSgmuVzxJqDlw5 l7vvypps2UT8Ro6pcTjMYRROnkXRwPsb8h9gToCujomdZaijAIS+yGz0IldOa3dswaf2 zKyvDypZV4X6qSUcSirx7p/LqwHYv3bEozBR1FotjCMJ07ky580j07eAr13PDzeExKPE 8HZA== X-Forwarded-Encrypted: i=1; AJvYcCXtz3ls9DBUYnuC+84r9MreCFAEtsa8mGKpCCDPNtb3iqT/q96JDPMFp6Cea2O0EJ/a0L6Mm/zCdmbTc88sWEJJeYg= X-Gm-Message-State: AOJu0YwV1Edj2Ody4yGagM3rCX4ITNGYTVFZv9/TBTqb+Lhjci5I1jbB l7eSRjW5TOJ27atgaVEo/ErHHbMEMcKsGZhwNVXNi6XT3Ml/D+O0f6LV/54fGQI= X-Google-Smtp-Source: AGHT+IGakITDK1e6MJJdG1G7doVOvxLMhuqD8/82B5UEd6Df7kliKIuuA82zI7ecR+7suaQ9ZP3OEw== X-Received: by 2002:a05:6830:46:b0:6e6:e639:6f22 with SMTP id d6-20020a056830004600b006e6e6396f22mr1930021otp.21.1712336198014; Fri, 05 Apr 2024 09:56:38 -0700 (PDT) Received: from localhost ([2620:10d:c091:400::5:bdbd]) by smtp.gmail.com with ESMTPSA id hb14-20020a05622a2b4e00b00430d494c75asm913892qtb.19.2024.04.05.09.56.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 09:56:36 -0700 (PDT) Date: Fri, 5 Apr 2024 12:56:32 -0400 From: Johannes Weiner To: Baolin Wang Cc: Andrew Morton , Vlastimil Babka , Mel Gorman , Zi Yan , "Huang, Ying" , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 06/10] mm: page_alloc: fix freelist movement during block conversion Message-ID: <20240405165632.GA870124@cmpxchg.org> References: <20240320180429.678181-1-hannes@cmpxchg.org> <20240320180429.678181-7-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 2EE7B180010 X-Rspam-User: X-Stat-Signature: 1c1kgj4st9nqt6nfz5rgg14ek97eyb5k X-Rspamd-Server: rspam01 X-HE-Tag: 1712336198-742740 X-HE-Meta: U2FsdGVkX18ZnFrC64jSpgWEjW8LSK14J1li1fSEE6THs7e3xazM+uDl+7Y+a+Bs1r52Gpvx9rkjg5U5m5jkYnqugR+q8fhzXxWtnNCl85+gi1ompPu+s+JZfq7M2F+mXTgyl8BgNnRxpcMhZWU2UTcmKVR/Us78eK7s1vuZNnKgq3s4GYVXgYQq6NW/VE3oaOP/zkkUMxeUrAbQhopvv3nIlG2BG72IDbCxUBMVXbCO2QT7VIFMgH75fmPHd+aMiMiFLaowQTwiW7agpv3nwdCbzbk6I9gqLVUGjvYxkDjnx2i1JED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G4XhOpqHBuhupzvrcrpyq845Id+Gntsp44HB2+NsBE82ynN701nIEAnuP6/9iHQ6nlsL5hcn7LF1zY1RveZs01l+P89nAwL4sf9CD+h9nSBvPORSZ2rwdy5BoDsD8qTipfrNckvpqSx/I73gZEPpWHCUpVCvAn2YYi9ZFxh4GAtp5NpfjYRS2+FA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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. 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.