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=-15.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_SANE_1 autolearn=unavailable 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 A2566C4338F for ; Fri, 6 Aug 2021 03:19:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9954761165 for ; Fri, 6 Aug 2021 03:19:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9954761165 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 063F86B006C; Thu, 5 Aug 2021 23:19:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 014126B0071; Thu, 5 Aug 2021 23:19:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E45A88D0001; Thu, 5 Aug 2021 23:19:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0049.hostedemail.com [216.40.44.49]) by kanga.kvack.org (Postfix) with ESMTP id C79906B006C for ; Thu, 5 Aug 2021 23:19:42 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 76D0210F79 for ; Fri, 6 Aug 2021 03:19:42 +0000 (UTC) X-FDA: 78443201004.23.068B6CA Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by imf28.hostedemail.com (Postfix) with ESMTP id D9E2790072E7 for ; Fri, 6 Aug 2021 03:19:40 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0Ui5yKU9_1628219977; Received: from 30.21.164.16(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Ui5yKU9_1628219977) by smtp.aliyun-inc.com(127.0.0.1); Fri, 06 Aug 2021 11:19:37 +0800 Subject: Re: [PATCH 5/5] mm: migrate: Remove redundant goto labels To: Yang Shi Cc: Andrew Morton , Linux MM , Linux Kernel Mailing List References: From: Baolin Wang Message-ID: <98937827-89ec-2a3b-b389-da28f8493cb1@linux.alibaba.com> Date: Fri, 6 Aug 2021 11:20:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D9E2790072E7 Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.57 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Stat-Signature: cskm56f7unjw1f7a8emyqcorrapmsf5f X-HE-Tag: 1628219980-300360 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: Hi Yang, > On Thu, Aug 5, 2021 at 8:06 AM Baolin Wang > wrote: >> >> Remove redundant goto labels to simplify the code. > > TBH I don't see too much benefit. The "goto" makes the functions have > a single exit point. Yes, I agree that the 'goto' statement can make things easier when a function exits from multiple locations and some common work such as cleanup has to be done, as well as introducing complexity to reading the code. So per the coding style documentation, "If there is no cleanup needed then just return directly", which can make code more readable I think :) But I have no strong opinion on this, I can drop this patch if you still think this is unnecessary. Thanks for your review and comments. >> Signed-off-by: Baolin Wang >> --- >> mm/migrate.c | 8 +++----- >> 1 file changed, 3 insertions(+), 5 deletions(-) >> >> diff --git a/mm/migrate.c b/mm/migrate.c >> index 0ab364f..ed74fda 100644 >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -911,9 +911,8 @@ static int move_to_new_page(struct page *newpage, struct page *page, >> */ >> VM_BUG_ON_PAGE(!PageIsolated(page), page); >> if (!PageMovable(page)) { >> - rc = MIGRATEPAGE_SUCCESS; >> __ClearPageIsolated(page); >> - goto out; >> + return MIGRATEPAGE_SUCCESS; >> } >> >> rc = mapping->a_ops->migratepage(mapping, newpage, >> @@ -949,7 +948,7 @@ static int move_to_new_page(struct page *newpage, struct page *page, >> flush_dcache_page(newpage); >> >> } >> -out: >> + >> return rc; >> } >> >> @@ -2095,11 +2094,10 @@ static struct page *alloc_misplaced_dst_page_thp(struct page *page, >> newpage = alloc_pages_node(nid, (GFP_TRANSHUGE_LIGHT | __GFP_THISNODE), >> HPAGE_PMD_ORDER); >> if (!newpage) >> - goto out; >> + return NULL; >> >> prep_transhuge_page(newpage); >> >> -out: >> return newpage; >> } >> >> -- >> 1.8.3.1 >> >>