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=-8.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,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 364AFC18E5B for ; Sun, 8 Mar 2020 08:44:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFE5420838 for ; Sun, 8 Mar 2020 08:44:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Y9sKlXPR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFE5420838 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 308606B0005; Sun, 8 Mar 2020 04:44:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28FF36B0006; Sun, 8 Mar 2020 04:44:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 158726B0007; Sun, 8 Mar 2020 04:44:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0135.hostedemail.com [216.40.44.135]) by kanga.kvack.org (Postfix) with ESMTP id EE0F26B0005 for ; Sun, 8 Mar 2020 04:44:36 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id BF4072C04 for ; Sun, 8 Mar 2020 08:44:36 +0000 (UTC) X-FDA: 76571558952.04.club96_b20057c4725d X-HE-Tag: club96_b20057c4725d X-Filterd-Recvd-Size: 3875 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Sun, 8 Mar 2020 08:44:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583657075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tKsi+IapMeAhWRUHAsgG1pQkti2JRC/jL+VSDNHEfmA=; b=Y9sKlXPRUrtUUO9/W6QoNe1I4h9OywhVOtOOrWE+VGUgEunEW4lymLuh43S16Q3OndcTaI 9qFlK1cYcVZrtGV7sT/RpUlzINSEw8qGgVSZlSuwhXfzh0lW9utxkFn4WXYCI9JdpapnLz l3wzhtBptdLWvMSSL3A5ohiwpwRoFDY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-430-9Lux3qStMhGsJOUBe0xX8w-1; Sun, 08 Mar 2020 04:44:33 -0400 X-MC-Unique: 9Lux3qStMhGsJOUBe0xX8w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BED5D8017CC; Sun, 8 Mar 2020 08:44:32 +0000 (UTC) Received: from localhost (ovpn-12-26.pek2.redhat.com [10.72.12.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC096272A5; Sun, 8 Mar 2020 08:44:31 +0000 (UTC) Date: Sun, 8 Mar 2020 16:44:29 +0800 From: Baoquan He To: qiwuchen55@gmail.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, chenqiwu Subject: Re: [PATCH] mm/page_alloc: simplify page_is_buddy() for better code readability Message-ID: <20200308084429.GM4937@MiWiFi-R3L-srv> References: <1583655036-5025-1-git-send-email-qiwuchen55@gmail.com> MIME-Version: 1.0 In-Reply-To: <1583655036-5025-1-git-send-email-qiwuchen55@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 03/08/20 at 04:10pm, qiwuchen55@gmail.com wrote: > From: chenqiwu >=20 > Simplify page_is_buddy() to reduce the redundant code for better > code readability. >=20 > Signed-off-by: chenqiwu > --- > mm/page_alloc.c | 13 +++---------- > 1 file changed, 3 insertions(+), 10 deletions(-) >=20 > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 79e950d..c6eef38 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -797,16 +797,8 @@ static inline void set_page_order(struct page *page,= unsigned int order) > static inline int page_is_buddy(struct page *page, struct page *buddy, > =09=09=09=09=09=09=09unsigned int order) > { > -=09if (page_is_guard(buddy) && page_order(buddy) =3D=3D order) { > -=09=09if (page_zone_id(page) !=3D page_zone_id(buddy)) > -=09=09=09return 0; > - > -=09=09VM_BUG_ON_PAGE(page_count(buddy) !=3D 0, buddy); > - > -=09=09return 1; > -=09} This duplicated removing Looks good, not sure if there's any performance impact or other considering. FWIW, Reviewed-by: Baoquan He > - > -=09if (PageBuddy(buddy) && page_order(buddy) =3D=3D order) { > +=09if ((page_is_guard(buddy) || PageBuddy(buddy)) > +=09 && page_order(buddy) =3D=3D order) { > =09=09/* > =09=09 * zone check is done late to avoid uselessly > =09=09 * calculating zone/node ids for pages that could > @@ -819,6 +811,7 @@ static inline int page_is_buddy(struct page *page, st= ruct page *buddy, > =20 > =09=09return 1; > =09} > + > =09return 0; > } > =20 > --=20 > 1.9.1 >=20 >=20