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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 C3BECC4320A for ; Fri, 6 Aug 2021 17:18:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98E3C611C6 for ; Fri, 6 Aug 2021 17:18:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240928AbhHFRSR (ORCPT ); Fri, 6 Aug 2021 13:18:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbhHFRSQ (ORCPT ); Fri, 6 Aug 2021 13:18:16 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70CA0C0613CF for ; Fri, 6 Aug 2021 10:17:59 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id f13so13969937edq.13 for ; Fri, 06 Aug 2021 10:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=akuG98DV2ldxk7RDY1w9lLgWyZHnVwVPQDD0gLmW4EI=; b=jT8ambbqt+XSdwwCcL2yCfnODT3i6eC9frjA1EAARfD9wCLS+WDDsyzA1/siLRxzQ3 4WUyhJ7GqaG6pqFZvVrpnWILJ45wI6Ek9rRnGx8M3t7sNezAZlf7t/Y+rPOOIdf6EKn/ qeGpIV3pejz+/sr12DQzvHrqFzL9MB2oUzYepyEf/9sFW0nKGv2+s93lozPlG9Zvw/hw 0GBQLxrInQOaCfdoE5pT+4ilHbg5+PLbmpRDG85QOFH5YRZF+Wn6+oM7RuVHqcE41qYC +1Im1MZJl/QUwP/HDgMDq1SEcbTHr2K1C5uMTTfhGoOpy+MbgK/rQG99nueMo3euvgc8 Gh+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=akuG98DV2ldxk7RDY1w9lLgWyZHnVwVPQDD0gLmW4EI=; b=g+9pT+2/qBA6o7EzPOKGZYRtXcfQh1I+HcndYiS2txk/JEPTcKOtkmj1T/QxS9KBk8 v6OZSJYkRu+yppbI0qDOFeCT8vjcu4gOR97nFeW7iwge20FwwmmdSVd8rYRHFDPlJZfz /qig973YXUnb/RkLxqhUbIh0EkYOHagu2q08R8+NJ88wf5ewKCnlnoYdKlJfNO/sw+6G JYtfql/TNZyYNHwHnJftDnor3ybHydBiUEpP4IqM+82p4jCps34M6p/3zfejxSdpyYi+ Oe6z6Kl2khUtFIwT2gQL1anm08xfJYxdUBfHzqKjk3rcwG1BXJsQHRCZUjFxK38o9yc4 3rQg== X-Gm-Message-State: AOAM531Ky/47KSJOE9smoTUz0v82z3hog4Rr61gew44LNAYXDUoq+swQ WuMl7Vo1E/c6AG45qBK6MmviDXMWzcgWCe56qdv5J+rUAIo= X-Google-Smtp-Source: ABdhPJwrR1PSnrQQSoNoiQt+kbY2/PgyWalfYpMMLO7+4WMAqsmImJ0GpJm5h61wk+FRmSJsvka3Bf3Piak21gS9Bh0= X-Received: by 2002:a05:6402:386:: with SMTP id o6mr14357685edv.294.1628270277721; Fri, 06 Aug 2021 10:17:57 -0700 (PDT) MIME-Version: 1.0 References: <98937827-89ec-2a3b-b389-da28f8493cb1@linux.alibaba.com> In-Reply-To: <98937827-89ec-2a3b-b389-da28f8493cb1@linux.alibaba.com> From: Yang Shi Date: Fri, 6 Aug 2021 10:17:46 -0700 Message-ID: Subject: Re: [PATCH 5/5] mm: migrate: Remove redundant goto labels To: Baolin Wang Cc: Andrew Morton , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 5, 2021 at 8:19 PM Baolin Wang wrote: > > 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. Thanks, IMHO I'd like to drop it for now. > > >> 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 > >> > >> 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 A2336C4338F for ; Fri, 6 Aug 2021 17:18:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 34D0A611C6 for ; Fri, 6 Aug 2021 17:18:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 34D0A611C6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 5DB2E8D0001; Fri, 6 Aug 2021 13:18:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 58C5B6B0071; Fri, 6 Aug 2021 13:18:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 479BB8D0001; Fri, 6 Aug 2021 13:18:00 -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 2AACC6B006C for ; Fri, 6 Aug 2021 13:18:00 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BDC4A182BCC4E for ; Fri, 6 Aug 2021 17:17:59 +0000 (UTC) X-FDA: 78445313478.03.A9A5D02 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by imf06.hostedemail.com (Postfix) with ESMTP id 3264A801CC6C for ; Fri, 6 Aug 2021 17:17:59 +0000 (UTC) Received: by mail-ed1-f42.google.com with SMTP id b7so14059084edu.3 for ; Fri, 06 Aug 2021 10:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=akuG98DV2ldxk7RDY1w9lLgWyZHnVwVPQDD0gLmW4EI=; b=jT8ambbqt+XSdwwCcL2yCfnODT3i6eC9frjA1EAARfD9wCLS+WDDsyzA1/siLRxzQ3 4WUyhJ7GqaG6pqFZvVrpnWILJ45wI6Ek9rRnGx8M3t7sNezAZlf7t/Y+rPOOIdf6EKn/ qeGpIV3pejz+/sr12DQzvHrqFzL9MB2oUzYepyEf/9sFW0nKGv2+s93lozPlG9Zvw/hw 0GBQLxrInQOaCfdoE5pT+4ilHbg5+PLbmpRDG85QOFH5YRZF+Wn6+oM7RuVHqcE41qYC +1Im1MZJl/QUwP/HDgMDq1SEcbTHr2K1C5uMTTfhGoOpy+MbgK/rQG99nueMo3euvgc8 Gh+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=akuG98DV2ldxk7RDY1w9lLgWyZHnVwVPQDD0gLmW4EI=; b=P1jSSWoF09AwXR26IH4ELg699P0H9NVOmgPaF/8yjauCvOzkjXBDaPRvdzxEikBE9y 7JH0ANEkWe7e2kIGkjHYon9oLV+l579kO1zxG4xttDeA+YJtNHy05+r4R83nNSh6EPtM ZA0wFM8AaH+kvlchjyaZtw6RCVGszRw1hrlpIXsIr+snKoAzzusqSLmeou5FJaO9omlq zN2zI+h6Ug00FlCL3S3nAVmhy87PqK6bFLeozSdiH4+ubFY/I/vtJASZDaVzTnEwekpC bSGk54bAT3sHb0kpTQQYyuzdj0/yK6zE+M7Zy6kBvkR0zDLlSd+04mMrOOVQRGYal/EB VcLw== X-Gm-Message-State: AOAM530lRbpq5/iyRtESwpUnkXce+a44JdgWvSiN+OLFVBtGKvJ+aiyH QaHa8LRpQZhfqdgFQnnUOzi/XQqfKYQcYq6QWbk= X-Google-Smtp-Source: ABdhPJwrR1PSnrQQSoNoiQt+kbY2/PgyWalfYpMMLO7+4WMAqsmImJ0GpJm5h61wk+FRmSJsvka3Bf3Piak21gS9Bh0= X-Received: by 2002:a05:6402:386:: with SMTP id o6mr14357685edv.294.1628270277721; Fri, 06 Aug 2021 10:17:57 -0700 (PDT) MIME-Version: 1.0 References: <98937827-89ec-2a3b-b389-da28f8493cb1@linux.alibaba.com> In-Reply-To: <98937827-89ec-2a3b-b389-da28f8493cb1@linux.alibaba.com> From: Yang Shi Date: Fri, 6 Aug 2021 10:17:46 -0700 Message-ID: Subject: Re: [PATCH 5/5] mm: migrate: Remove redundant goto labels To: Baolin Wang Cc: Andrew Morton , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3264A801CC6C Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=jT8ambbq; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.42 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-Stat-Signature: rzpjqk96cjxykocrdrob3amxmoq6818k X-HE-Tag: 1628270279-724962 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 Thu, Aug 5, 2021 at 8:19 PM Baolin Wang wrote: > > 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. Thanks, IMHO I'd like to drop it for now. > > >> 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 > >> > >>