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 X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CB8AC43457 for ; Mon, 19 Oct 2020 11:39:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 35BD422263 for ; Mon, 19 Oct 2020 11:39:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=windriversystems.onmicrosoft.com header.i=@windriversystems.onmicrosoft.com header.b="oD+6DWbs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 35BD422263 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=windriver.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 444C96B005D; Mon, 19 Oct 2020 07:39:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F52B6B0062; Mon, 19 Oct 2020 07:39:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BDE46B0068; Mon, 19 Oct 2020 07:39:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0050.hostedemail.com [216.40.44.50]) by kanga.kvack.org (Postfix) with ESMTP id F333E6B005D for ; Mon, 19 Oct 2020 07:39:54 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 97272180AD811 for ; Mon, 19 Oct 2020 11:39:54 +0000 (UTC) X-FDA: 77388480708.08.anger93_231596c27236 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 759AD1819E766 for ; Mon, 19 Oct 2020 11:39:54 +0000 (UTC) X-HE-Tag: anger93_231596c27236 X-Filterd-Recvd-Size: 11004 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2057.outbound.protection.outlook.com [40.107.243.57]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Mon, 19 Oct 2020 11:39:53 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G1VvCo9ZqqLeBm2PkBUxSs+qBPC2q/+6pk/+NAjaJvip4JvWh/hilbz6FlYmpGthJz4o8fh0sqX1Yj8IsBjAPYaI6UqIFLHNC4GAwRB3cYnq11xVRr3gxL0SLwmnsBqkpmZ2bbvbnO30p8bt77/s0Mbaqe3d7l2XjMQud0FxcUMjIHMpSJEpBqMh+ssE8M96IEPteBpMFSHustZZC58+m2pHGAd0BI8idYJj3zkQhwxChChaD+LIZa7xXr40IwVOClvWZ4JfCoTBIhOZS83isLEM3ZicMetcFikVakRfYrqQWRqitY2WJ4tz8WgYE00C4c+EWGsumsZC/USi+RYnwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/kUPtAz5kVrCUQD2nKxNMRYSAzzg+qBtwMcU1Z+kxmY=; b=mi0IbkGielXjQsFRl01fhuiBavomS7W5VGxUoyq0NFvfKDTl5tu3LvYTxwahgoodSfgDKbWVca6jMwblL6lCodjeXoyNUTR0NaOrGvUf23QJD3y74r1HJezaUc+ZhxKBWgsuUyjBoQ4au5rosfxQmCNdlJZ9FmhqBFzdCSw0tRTQio5GC5YmJGnKWw6qzzxCfEpLqBlIdTgKzNOiG5u2v6hPMXOCsmNjoscXpPoIGYqWftphXLJUgsvlp7DqYTvpbF1ZKfIK8I2fHkvaZ9FldzpNMHxFxmLxKm5LeBQ6Ds2FyTbsKpMcqS8WORhkFVkqcG7BsicoISYSp8BHZEuQwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/kUPtAz5kVrCUQD2nKxNMRYSAzzg+qBtwMcU1Z+kxmY=; b=oD+6DWbskU2thXvIOgdW1yuLnRC8uW9NlOPyryKJLbZ0YEkAuXVgn5nXEJ2Trsbff75n64FtkJ02lPxKfAXKvENB5FiTukXNnWkU/pgtwd81W1AuSRVh0i8xlItp9YfW4G9h8qLFHOcz72iD3XyMSkoq+uyIjUHiB3wP9P0SH08= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=windriver.com; Received: from BY5PR11MB4241.namprd11.prod.outlook.com (2603:10b6:a03:1ca::13) by BYAPR11MB2839.namprd11.prod.outlook.com (2603:10b6:a02:c8::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.25; Mon, 19 Oct 2020 11:39:50 +0000 Received: from BY5PR11MB4241.namprd11.prod.outlook.com ([fe80::adbd:559a:4a78:f09b]) by BY5PR11MB4241.namprd11.prod.outlook.com ([fe80::adbd:559a:4a78:f09b%6]) with mapi id 15.20.3477.028; Mon, 19 Oct 2020 11:39:49 +0000 Subject: Re: [PATCH v2] mm/compaction: Rename 'start_pfn' to 'iteration_start_pfn' in compact_zone() To: Vlastimil Babka , akpm@linux-foundation.org, david@redhat.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20201019083632.25417-1-yanfei.xu@windriver.com> <57730b8a-f5d7-d6c7-3961-3fa95701aba5@suse.cz> <4aa294a0-c256-7e89-55af-6a7c790eec4d@windriver.com> <0480a649-9f49-90fe-fbf2-be1d2df306f0@suse.cz> From: "Xu, Yanfei" Message-ID: Date: Mon, 19 Oct 2020 19:39:41 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 In-Reply-To: <0480a649-9f49-90fe-fbf2-be1d2df306f0@suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Originating-IP: [60.247.85.82] X-ClientProxiedBy: HK0PR01CA0049.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::13) To BY5PR11MB4241.namprd11.prod.outlook.com (2603:10b6:a03:1ca::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [128.224.162.160] (60.247.85.82) by HK0PR01CA0049.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21 via Frontend Transport; Mon, 19 Oct 2020 11:39:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 067a3580-682d-4458-41fd-08d87423afbb X-MS-TrafficTypeDiagnostic: BYAPR11MB2839: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:669; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: soqCw9asecWnQBNyUZsG6VwnG+OiB5NrgJldKy7aAk5nbuGYtFWl8dYSNPxvJ7IScfTDJq29nh9BqswY8bL6/rciun0xUEYj+BeEjgGj/AcvbhKyD6fnNLVje/2N0+DSTORS7Yse8R5VXowBIPTZ8KKmvToC9QbmTUf4wJZmVWV1nblr4A1/oz1UGmXT7VXqPqLC0SG6Gx426QhvnSJjIKBs1mGi836hGk3yxE9UK10DGeWQeMnxSsZFncDp4Qp14nfVpa/RtHmqBv5+MOd/fE1T/wMpRnOFU3P2rBdMGcyebe1MfIDeUN3mJxkskoMDbf/gy0Zx7gXfbQ5kHoJLCVEHGXz0R6+5EqkwURM8Bnlff1gsy/W5uJnd3vmlJwfo2c/vMoGxKUBmO6hWpGIWRw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR11MB4241.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(346002)(136003)(39850400004)(396003)(31686004)(5660300002)(52116002)(6706004)(316002)(66476007)(6486002)(186003)(16526019)(16576012)(66556008)(31696002)(4326008)(36756003)(26005)(66946007)(6666004)(478600001)(8936002)(86362001)(2906002)(2616005)(8676002)(956004)(83380400001)(53546011)(78286007)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Uh30ypT3Gr0290PT9q2KUR0vQqyNCghuWFGRfHEjAaEcVErtIPARr/elVESjzi46S3HuMBDKt1ZvOCwjv7d+ymGw/6BOeNtv/4u57HA9eYk3pT5dCPjzg6utPn/qe7sTvfiBSx1/H16S3dEL4wVKV0+D2+++5z/OOIzeCnSQolhppxBg6wSDsEVZgyuYPak9K6Yk3O6OdS8p4qTGCYRDL2BB2r/0SSZgkpobfGm+eiOeNZEapPymp/WeFEWtthZGmt55HAvLcvNtl15IxHTlI3i9E+NUfjmV4L0HlNgysMicjul9WWFITdGkeGXs/b0YE5SfGYJszrsOW7P2uPcrqJfzBXjB79kVr5/r3t88aPFq15Q7Q+76pO2O/9POvX02bSkPVL91qVNcsipdX2trrD6nk0QtCfZmDx8nw833rVBFdl54ukB5IkSq9vZahl1rTSMIjVct7c8+NOEGS4gt8uqFL7u12H54zDlXnEdscDaEuZZ7qo084BkeF2/iSNlh1CyMgzlgBd98mmF21ht/ZSpvGVVpmNoMtLsx8ZbKpNN21Twy9QVeNcARV5+0v64OmmAj7W/l4+Ns8WoBZQEQ8428WiA054fbockWVkb5siwEvsStrOA+FRnNQy05dNb5xqDmkQ37Mtuu5KU8b4wiWw== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 067a3580-682d-4458-41fd-08d87423afbb X-MS-Exchange-CrossTenant-AuthSource: BY5PR11MB4241.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2020 11:39:49.6086 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: csJYdv3pT1ibt+HQGxW4+vpcFekIWqgK5xXA/GMFRsAF2CavTRJF7EM9jGVIGv9KuDPeWUaLmtwcXdyG9OFZxw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2839 Content-Transfer-Encoding: quoted-printable 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: On 10/19/20 6:48 PM, Vlastimil Babka wrote: > On 10/19/20 12:29 PM, Xu, Yanfei wrote: >> >> >> On 10/19/20 5:40 PM, Vlastimil Babka wrote: >>> On 10/19/20 10:36 AM, yanfei.xu@windriver.com wrote: >>>> From: Yanfei Xu >>>> >>>> There are two 'start_pfn' declared in compact_zone() which have >>>> different meaning. Rename the second one to 'iteration_start_pfn' >>>> to prevent trace_mm_compaction_end() from tracing an undesirable >>>> value. >>> >>> "to prevent confusion.", because trace_mm_compaction_end() has the >>> correct value even before the patch - the second start_pfn is out >>> of scope at that point. >>> >>> Thanks >>> >> In the while-statement, the second start_pfn is always be reassigned t= he >> value of cc->migrate_pfn in every loop, also the cc->migrate_pfn might >> be changed in the loop. Does trace_mm_compaction_end() really want to >> trace the new assinged start_pfn? >=20 > compact_zone() > { > =C2=A0=C2=A0=C2=A0 unsigned long start_pfn =3D cc->zone->zone_start_pf= n; >=20 > =C2=A0=C2=A0=C2=A0 while ((ret =3D compact_finished(cc)) =3D=3D COMPAC= T_CONTINUE) { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned long start_pfn =3D= cc->migrate_pfn; > =C2=A0=C2=A0=C2=A0=C2=A0... > =C2=A0=C2=A0=C2=A0 } >=20 > =C2=A0=C2=A0=C2=A0 trace_mm_compaction_end(start_pfn, cc->migrate_pfn,= ...) > } >=20 > Unless my C knowledge fails me completely, the start_pfn in the while=20 > loop is a new different local variable that shadows the start_pfn from=20 > compact_zone() level, but does not modify its value. After while loop=20 > finishes, start_pfn has still the value assigned at > compact_zone() beginning and that's what tracepoint sees. >=20 You are right! and I got your point. As you said, the second start_pfn=20 is out of scope at that point. Will send v3. Many thanks, Yanfei > So renaming the variable in while loop is not a bug fix, but removing=20 > confusion. >=20 >> Without the patch=EF=BC=9A 566e54e11=EF=BC=88mm, compaction: remove la= st_migrated_pfn >> from compact_control=EF=BC=89, there is only one start_pfn which has a= fixed >> value. The trace_mm_compaction_end() trace it too. >> >> Thus, I think the tracepoint might get an undesireble value.:) >> >> Thanks, >> Yanfei >> >>>> BTW, remove an useless semicolon. >>>> >>>> Acked-by: David Hildenbrand >>>> Acked-by: Vlastimil Babka >>>> Signed-off-by: Yanfei Xu >>>> --- >>>> v1->v2: >>>> Rename 'start_pfn' to 'iteration_start_pfn' and change commit messag= es. >>>> >>>> =C2=A0 mm/compaction.c | 7 +++---- >>>> =C2=A0 1 file changed, 3 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/mm/compaction.c b/mm/compaction.c >>>> index 176dcded298e..ccd27c739fd6 100644 >>>> --- a/mm/compaction.c >>>> +++ b/mm/compaction.c >>>> @@ -2272,7 +2272,7 @@ compact_zone(struct compact_control *cc,=20 >>>> struct capture_control *capc) >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 while ((ret =3D compact_finished(cc))= =3D=3D COMPACT_CONTINUE) { >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int err; >>>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned long start_pfn = =3D cc->migrate_pfn; >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned long iteration_= start_pfn =3D cc->migrate_pfn; >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * Avoid= multiple rescans which can happen if a page=20 >>>> cannot be >>>> @@ -2284,7 +2284,7 @@ compact_zone(struct compact_control *cc,=20 >>>> struct capture_control *capc) >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cc->rescan =3D= false; >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (pageblock= _start_pfn(last_migrated_pfn) =3D=3D >>>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = pageblock_start_pfn(start_pfn)) { >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = pageblock_start_pfn(iteration_start_pfn)) { >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 cc->rescan =3D true; >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >>>> @@ -2308,8 +2308,7 @@ compact_zone(struct compact_control *cc,=20 >>>> struct capture_control *capc) >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 goto check_drain; >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 case ISOLATE_= SUCCESS: >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 update_cached =3D false; >>>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = last_migrated_pfn =3D start_pfn; >>>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = ; >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = last_migrated_pfn =3D iteration_start_pfn; >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 err =3D migra= te_pages(&cc->migratepages, compaction_alloc, >>>> >>> >>> >> >=20