Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3569512pxu; Mon, 19 Oct 2020 15:48:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZ2vO3Cfsqp6tMkz8Lsc2pAB8pkWUKaBJCRUhuZm9ONIAjj0z7T4yOK1j/xbbWDZ1CktJT X-Received: by 2002:a05:6402:a42:: with SMTP id bt2mr2064815edb.193.1603147715021; Mon, 19 Oct 2020 15:48:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603147715; cv=none; d=google.com; s=arc-20160816; b=Zu02gh4pjWyJeRhwT/pFlNJ+9AXUouikV7FOUvoP/YpwqPxV4KYtuLMT1L/MHkhavc 3FRly3/DWT0yxTbWCKCb63DEMlEy+kXR8goYOR/KhCa/jra2UL48caiw61UxIw/+V3tf ChRPmmAtPVuGJ56nLCxgrWTpIw5B1fYFcsheikvjhyDugR6RGVgois6SCV+zGsKOpMcv F/LvXE9mTABEYpvn5lxW6hGsCNPvufDIEw4oYwSJZF0bau0QHmkjGTrs5U78bfxnMuMm /x8an0EQDdLzgY9gNi/qCTxDoPVTGVgzCTckCISajZR4TtbdyWCoi45AiubhO84wC906 WdMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to; bh=S0E1P0/f1/iqnraR9t0GTkGnGCOy9oYcko+4tBqCuQ0=; b=jEjPIzcXESnwGHGc5gtTUk0wmneCuu5vZo2BpNop7VADSdWbKABtZgfTLcM2FpC7+Y GKF6jZTr4Y+Cliue9USRhNzu7za9kbPNBaBc+uJznVoBQPGcjhhWyPIBdOII+3ImH0pA t62F5sR7bfbkmuUnIkINas2ongnNBJcvzMWm0AwS5fKsWDfS2Nrpfu5ZnprDPN+UuLIa zl+3bFDqLGC3SBKZiIx8bzi1d4FrbA9FyxmKCQBUFPPx33PWsRxoKvy9+VWlGdtDCuuz wqijhn5gs9AxikNLKPfFFOoR2MhY+GK3PDPX5ojEs9QEEfjupeOeAvgfRstnBMl1mJ7W giYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx24si937799ejb.449.2020.10.19.15.48.13; Mon, 19 Oct 2020 15:48:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727238AbgJSKse (ORCPT + 99 others); Mon, 19 Oct 2020 06:48:34 -0400 Received: from mx2.suse.de ([195.135.220.15]:53298 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727037AbgJSKsb (ORCPT ); Mon, 19 Oct 2020 06:48:31 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 54CCBACAC; Mon, 19 Oct 2020 10:48:29 +0000 (UTC) To: "Xu, Yanfei" , 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> From: Vlastimil Babka Subject: Re: [PATCH v2] mm/compaction: Rename 'start_pfn' to 'iteration_start_pfn' in compact_zone() Message-ID: <0480a649-9f49-90fe-fbf2-be1d2df306f0@suse.cz> Date: Mon, 19 Oct 2020 12:48:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.2 MIME-Version: 1.0 In-Reply-To: <4aa294a0-c256-7e89-55af-6a7c790eec4d@windriver.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 the > 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? compact_zone() { unsigned long start_pfn = cc->zone->zone_start_pfn; while ((ret = compact_finished(cc)) == COMPACT_CONTINUE) { unsigned long start_pfn = cc->migrate_pfn; ... } trace_mm_compaction_end(start_pfn, cc->migrate_pfn, ...) } Unless my C knowledge fails me completely, the start_pfn in the while loop is a new different local variable that shadows the start_pfn from compact_zone() level, but does not modify its value. After while loop finishes, start_pfn has still the value assigned at compact_zone() beginning and that's what tracepoint sees. So renaming the variable in while loop is not a bug fix, but removing confusion. > Without the patch: 566e54e11(mm, compaction: remove last_migrated_pfn > from compact_control), 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 messages. >>> >>>   mm/compaction.c | 7 +++---- >>>   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, struct >>> capture_control *capc) >>>       while ((ret = compact_finished(cc)) == COMPACT_CONTINUE) { >>>           int err; >>> -        unsigned long start_pfn = cc->migrate_pfn; >>> +        unsigned long iteration_start_pfn = cc->migrate_pfn; >>>           /* >>>            * Avoid multiple rescans which can happen if a page cannot be >>> @@ -2284,7 +2284,7 @@ compact_zone(struct compact_control *cc, struct >>> capture_control *capc) >>>            */ >>>           cc->rescan = false; >>>           if (pageblock_start_pfn(last_migrated_pfn) == >>> -            pageblock_start_pfn(start_pfn)) { >>> +            pageblock_start_pfn(iteration_start_pfn)) { >>>               cc->rescan = true; >>>           } >>> @@ -2308,8 +2308,7 @@ compact_zone(struct compact_control *cc, struct >>> capture_control *capc) >>>               goto check_drain; >>>           case ISOLATE_SUCCESS: >>>               update_cached = false; >>> -            last_migrated_pfn = start_pfn; >>> -            ; >>> +            last_migrated_pfn = iteration_start_pfn; >>>           } >>>           err = migrate_pages(&cc->migratepages, compaction_alloc, >>> >> >> >