From patchwork Sun Mar 8 08:10:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenqiwu X-Patchwork-Id: 11425485 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C8D0A921 for ; Sun, 8 Mar 2020 08:10:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8D5EE2146E for ; Sun, 8 Mar 2020 08:10:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bVGZXFm4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D5EE2146E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8019D6B0005; Sun, 8 Mar 2020 04:10:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7B4BE6B0006; Sun, 8 Mar 2020 04:10:43 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6794E6B0007; Sun, 8 Mar 2020 04:10:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id 4BF816B0005 for ; Sun, 8 Mar 2020 04:10:43 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1C166181AC9C6 for ; Sun, 8 Mar 2020 08:10:43 +0000 (UTC) X-FDA: 76571473566.21.card69_63aed2ea6d57 X-Spam-Summary: 2,0,0,2a8ee602d6eaa9d8,d41d8cd98f00b204,qiwuchen55@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2731:3138:3139:3140:3141:3142:3352:3865:3867:3871:3874:4321:5007:6261:6653:7576:8957:9413:9592:10004:11026:11232:11473:11658:11914:12043:12297:12517:12519:12555:12679:12895:13069:13311:13357:14096:14181:14384:14394:14721:21080:21094:21323:21444:21451:21627:21666:21990:30012:30054:30070,0,RBL:209.85.210.193:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: card69_63aed2ea6d57 X-Filterd-Recvd-Size: 3741 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Sun, 8 Mar 2020 08:10:42 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id 23so1598825pfj.1 for ; Sun, 08 Mar 2020 00:10:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=xluHgKbqag1C+hNveC9XOA1+hLsrjihJIGGW4ge98mM=; b=bVGZXFm4EdGQ/ndLzntAmME5tazWM7YHA6dlF8xXohU/r0ssK75suFRX0P+zzPgN78 GihdmNuRWa8ypvkzMN71f4ILAV5tmzB9ztIzTlIjUzkWciQ3ubb52FJnR4a+TgxRVhpA URKI9q0dnGVSy9l4x1E99BK1Muv5m6SZrrmYO/sMNqzmU14yaiz5UBl4OjuMKttRNwjY NAOKXkM50x5kuZ4RJbKkSjwzvBsPzY+1fj0r2cHhYvhCmbsiwPrID/j6sr560cL5qzKU QpGW1oJdTrBDawmmxY4SMKqukmK2XoKXOZzvuOEa/zWnS29tc7JWMe1yDDq1EMloQXxl uJgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xluHgKbqag1C+hNveC9XOA1+hLsrjihJIGGW4ge98mM=; b=hH/0fZc/VOI249Wg0VVlpgUoI27Q9xJSriSYpnBs4k5ZXSH3Hp7ROuxuwKPdk/KobG uOK/y6RJn0cKgNQEdom6SJofRMGkGWJ9PLkWD7LBfSCEpAuRYa7s9bQr1PwGA4cI8QHq Fd+HEdlIKTciPZ+j7ljF0HlRtbYFWqP3hp4BHZQ3/PbiU7cFbr6ZBEzQLl+v/7bHENV+ vtOB/s5eU4BdnhXNFVswjcXZYhOSvaar4XY/2DzNx80cinb+1HHgvS8W09N8uwCOBRIb OBF3L0Fv6nGIzNu+3sEXHE/hh0LYeODUaCmriBpfkPWyTMpEO3Xr4zicFq7/4z+oCefy RIQA== X-Gm-Message-State: ANhLgQ0/UUEOjNUra6861NAyAo8iG3UW35dm1AEedX91aL0wDfsPGcyL lj4KeZTW6h2Ice2Vwm/P3Ws= X-Google-Smtp-Source: ADFU+vtKCKpcm4c18uliIwkUCTioPFVvFAbwzOyRMs7X/798g35NPPPOVwPvzRE1rRNusEyBy2IWQQ== X-Received: by 2002:a63:f010:: with SMTP id k16mr10900033pgh.328.1583655041438; Sun, 08 Mar 2020 00:10:41 -0800 (PST) Received: from localhost ([43.224.245.179]) by smtp.gmail.com with ESMTPSA id h2sm39749621pgv.40.2020.03.08.00.10.40 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 08 Mar 2020 00:10:40 -0800 (PST) From: qiwuchen55@gmail.com To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, chenqiwu Subject: [PATCH] mm/page_alloc: simplify page_is_buddy() for better code readability Date: Sun, 8 Mar 2020 16:10:36 +0800 Message-Id: <1583655036-5025-1-git-send-email-qiwuchen55@gmail.com> X-Mailer: git-send-email 1.9.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000035, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: chenqiwu Simplify page_is_buddy() to reduce the redundant code for better code readability. Signed-off-by: chenqiwu Reviewed-by: Baoquan He Reviewed-by: Matthew Wilcox (Oracle) Acked-by: Pankaj Gupta --- mm/page_alloc.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) 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, unsigned int order) { - if (page_is_guard(buddy) && page_order(buddy) == order) { - if (page_zone_id(page) != page_zone_id(buddy)) - return 0; - - VM_BUG_ON_PAGE(page_count(buddy) != 0, buddy); - - return 1; - } - - if (PageBuddy(buddy) && page_order(buddy) == order) { + if ((page_is_guard(buddy) || PageBuddy(buddy)) + && page_order(buddy) == order) { /* * zone check is done late to avoid uselessly * calculating zone/node ids for pages that could @@ -819,6 +811,7 @@ static inline int page_is_buddy(struct page *page, struct page *buddy, return 1; } + return 0; }