Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp873245rdb; Wed, 6 Dec 2023 02:18:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/DtYjDl4CDi/lGbzB4jGBRsqqCIMQnHVDlwZSv5cwJV8XlnQl67VTEdxQIt10V2ThMDZ3 X-Received: by 2002:a05:6a21:3102:b0:188:f3d:ea35 with SMTP id yz2-20020a056a21310200b001880f3dea35mr965204pzb.50.1701857939213; Wed, 06 Dec 2023 02:18:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701857939; cv=none; d=google.com; s=arc-20160816; b=HJdHxGr3Ub2vRN5RAsS6esGqL90GH81xVz6BhkXIF/vlBZHSLJjopwMXXbgCRwSYy/ ZzWrB0d/O7POgT8Z4nTpNaGLHs9DfXf0MzW+Kvf9vWBXWq1MecUjAEDz7Mfk3R5OHNBG 7qLAZvciXmUCcXPoxTYOY5vy23LCwX0Rfcn0P7+wOxzOCHI3TiLDvMRXwctxgQkuiBYh KDnZBGp5SmJ+XUaD7+xA1eUAIoLdT+VpugvqBeavQZlkek1DDp/Bht/7S4v2kw9t3PdO Pk332ManH6gHpQb+ipTRU3R3AI969O2kdkt1l6NEfQDEHs8+5KkRXxgaGJJnTeseVOzQ lYKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=PB5sZ5MSZmZsnlatsjzNG0ijjFc2lOy26kZJCTP898Q=; fh=RbQDztOESqu/0aZsRkqvg62CDBZ39nKhVHbwSsf/gMU=; b=uIIhZ3A9z9PLjfYixzakDsUai5cC7gOmS7BCn38hwpHCDlgIlqwV4pInTaockBLLFR kFj6y+UpTLQao5hcc6NJ4LJ4FiGKgtoVu0p3FfBVX5pLI+r01HbZOZTvN4D0OU8ZnwPT YkKc7/3+WLGvoq9enxxE65Y2ZePfMz/WRhoXtsA6NSzBDkXRSXH33cqwL4mWp++LzSxG 0sofa9YmAKyUfrMn0gMq7eUAaqZu+jDSifiKJTvD8lEfb8beOlpbGe13uGdzxBOKr7Nm D4YwKryOI+00t1jDPna/AYpCJIOrcG7gd1D/UOgK89il7u5vZfGTXhSXriLOZkyEpOCZ 0SHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RZGcPZqX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id u16-20020a056a00125000b006ce08cdaf39si8572974pfi.386.2023.12.06.02.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:18:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RZGcPZqX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 42D5B8165391; Wed, 6 Dec 2023 02:18:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377607AbjLFKSk (ORCPT + 99 others); Wed, 6 Dec 2023 05:18:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377549AbjLFKSj (ORCPT ); Wed, 6 Dec 2023 05:18:39 -0500 Received: from mail-vs1-xe30.google.com (mail-vs1-xe30.google.com [IPv6:2607:f8b0:4864:20::e30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5DD98F for ; Wed, 6 Dec 2023 02:18:45 -0800 (PST) Received: by mail-vs1-xe30.google.com with SMTP id ada2fe7eead31-46495e57cdeso578913137.3 for ; Wed, 06 Dec 2023 02:18:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701857925; x=1702462725; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PB5sZ5MSZmZsnlatsjzNG0ijjFc2lOy26kZJCTP898Q=; b=RZGcPZqXMA0agsSEY6/QfvG6mKWhOvS/+WAb0TiZJb8urUGJYVq8nnDRaDetc6kfBe iOWp26tO2gqJmZXBGFRwdMxmtEJTVLS/FgzyceOhuUYSx/C/EN4EufnwzQ85d0IQOt9H uvU4sch2u36DP8SxzZUuMIZwPqlowIkDFciWFQyRdeupUyh1CdAT3oJHy4s+J7YdE7/o 8IIVclnUVFkV0yNFRhT4+8Q2Aje485zdVPXf5MNv4sG2gCK/HRTRgYtero3JyGnnrjTv 98DQR9BpejKCVI4FlTvgNCNk1oQXPLeGQ80cKATZ5WDMEcdqAVWjRU/D0vvIFcYm2oMH tC1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701857925; x=1702462725; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PB5sZ5MSZmZsnlatsjzNG0ijjFc2lOy26kZJCTP898Q=; b=s8QDwFBuQ3Q1V0C3rKA6ws26dL9NkZueO1elg8judCqNYxJYaxYvb5/KNlB2sIQ+AE lH9JvH1T2XB2Q7g1bpPxvtdhfDneEUK7VbNpGreQrjGhgdATcQbivU4zyygOwQKss3A3 Z7exspeIuxHDqnT6RzkQIFPWKswHoQ8sYcTbqzjxFFlDolmfOmM8f+8Wjyes9p2NKwyH N/5/IgAWXpgFQvHAy6duXLh076jNqQV5S8GoaCynThJNCpGFePXJNyfEVtKSFCbanW5l pPFfqaRPgnKRCqEswRs9LsHBKsOqa/T4MFZ7rtt4NCdMdisk+GEvaGGS/PyHAzsfT0o7 cT+Q== X-Gm-Message-State: AOJu0YxE/63sUga4Ga4lb8wB6MoqFm7T2GUFRUTWno7fTK4YSOlCw8Ua O5w4qOkIDBXpxcROxV661DnLOB3ga2Bq/yioNMM= X-Received: by 2002:a05:6102:7b8:b0:464:95d9:8d39 with SMTP id x24-20020a05610207b800b0046495d98d39mr170221vsg.27.1701857924667; Wed, 06 Dec 2023 02:18:44 -0800 (PST) MIME-Version: 1.0 References: <20231129104530.63787-1-v-songbaohua@oppo.com> <079610c2-04ed-4495-8eb7-518b04f911f7@linux.alibaba.com> In-Reply-To: <079610c2-04ed-4495-8eb7-518b04f911f7@linux.alibaba.com> From: Barry Song <21cnbao@gmail.com> Date: Wed, 6 Dec 2023 23:18:32 +1300 Message-ID: Subject: Re: [RFC PATCH] mm: compaction: avoid fast_isolate_freepages blindly choose improper pageblock To: Baolin Wang Cc: akpm@linux-foundation.org, linux-mm@kvack.org, david@redhat.com, shikemeng@huaweicloud.com, willy@infradead.org, mgorman@techsingularity.net, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, Barry Song , Zhanyuan Hu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 02:18:56 -0800 (PST) On Wed, Dec 6, 2023 at 10:54=E2=80=AFPM Baolin Wang wrote: > > > > On 11/29/2023 6:45 PM, Barry Song wrote: > > Testing shows fast_isolate_freepages can blindly choose an unsuitable > > pageblock from time to time particularly while the min mark is used > > from XXX path: > > if (!page) { > > cc->fast_search_fail++; > > if (scan_start) { > > /* > > * Use the highest PFN found above min. If one was > > * not found, be pessimistic for direct compaction > > * and use the min mark. > > */ > > if (highest >=3D min_pfn) { > > page =3D pfn_to_page(highest); > > cc->free_pfn =3D highest; > > } else { > > if (cc->direct_compaction && pfn_valid(min_pf= n)) { /* XXX */ > > page =3D pageblock_pfn_to_page(min_pf= n, > > min(pageblock_end_pfn(min_pfn= ), > > zone_end_pfn(cc->zone)), > > cc->zone); > > cc->free_pfn =3D min_pfn; > > } > > } > > } > > } > > Yes, the min_pfn can be an unsuitable migration target. But I think we > can just add the suitable_migration_target() validation into 'min_pfn' > case? Since other cases must be suitable target which found from > MIGRATE_MOVABLE free list. Something like below: > > diff --git a/mm/compaction.c b/mm/compaction.c > index 01ba298739dd..4e8eb4571909 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -1611,6 +1611,8 @@ static void fast_isolate_freepages(struct > compact_control *cc) > > min(pageblock_end_pfn(min_pfn), > > zone_end_pfn(cc->zone)), > cc->zone); > + if > (!suitable_migration_target(cc, page)) > + page =3D NULL; > cc->free_pfn =3D min_pfn; > } > } > yes. this makes more senses. > By the way, I wonder if this patch can improve the efficiency of > compaction in your test case? This happens not quite often. when running 25 machines for one night, most of them can hit this unexpected code path. but the frequency isn't many times in one second. it might be one time in a couple of hours. so it is very difficult to measure the visible performance impact in my machines though the affection of choosing the unsuitable migration_target should be negative. I feel like it's worth fixing this to at least make the code theoretically self-explanatory? as it is quite odd unsuitable_migration_target can be still migration_target? > > > In contrast, slow path is skipping unsuitable pageblocks in a decent wa= y. > > > > I don't know if it is an intended design or just an oversight. But > > it seems more sensible to skip unsuitable pageblock. > > > > Reported-by: Zhanyuan Hu > > Signed-off-by: Barry Song > > --- > > mm/compaction.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/mm/compaction.c b/mm/compaction.c > > index 01ba298739dd..98c485a25614 100644 > > --- a/mm/compaction.c > > +++ b/mm/compaction.c > > @@ -1625,6 +1625,12 @@ static void fast_isolate_freepages(struct compac= t_control *cc) > > cc->total_free_scanned +=3D nr_scanned; > > if (!page) > > return; > > + /* > > + * Otherwise, we can blindly choose an improper pageblock especia= lly > > + * while using the min mark > > + */ > > + if (!suitable_migration_target(cc, page)) > > + return; > > > > low_pfn =3D page_to_pfn(page); > > fast_isolate_around(cc, low_pfn); Thanks Barry