From patchwork Tue Dec 11 03:51:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10723013 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1013F13AF for ; Tue, 11 Dec 2018 03:51:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 003392AC03 for ; Tue, 11 Dec 2018 03:51:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E903A2AC4B; Tue, 11 Dec 2018 03:51:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 923C12AC4C for ; Tue, 11 Dec 2018 03:51:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24C008E004E; Mon, 10 Dec 2018 22:51:37 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1FB598E004D; Mon, 10 Dec 2018 22:51:37 -0500 (EST) 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 0EA778E004E; Mon, 10 Dec 2018 22:51:37 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id C1AD08E004D for ; Mon, 10 Dec 2018 22:51:36 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id t2so11579875pfj.15 for ; Mon, 10 Dec 2018 19:51:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=IVawOnQaWNEvgVWi+BphS0nrxrPkdnIoZUeATJdwRs8=; b=jy852F1N2R24ZQZgMSoZ2c3mIGTjRVCQhl9ZceO1Mbtlmtg4fh1xbV3VsQctOeN+UT QwrtHHq5SEjlveXdd9IhGy4E0loz5szl9FYRgXYYbEbVfJxsA+sIfOmtiDUWzn6cesjy DIALQNvBioCFAH2dgXbyfHR8TBLG9sJ3RivCBJT9PQ2vwdxTminpcw1XfCFNOxO2kULS fgK67LxKpmBImdimAMQQuiFcrJd73tGZS8VVSjJ+C++aSyJKFNAnhB85Z3JrUsdDZjSu xcYjiCtaIQT3LuXKI71qL6nPr18bo7IVbyyK8kgdFXRyk2wJim52DFIws57zEG1wko16 NsfA== X-Gm-Message-State: AA+aEWbbSNB9QcqJ2OVHI5Wk0ZfPGLPdBmMXsHfKjPayTuO0iTuzATJr xxyPrhXumaL6kXSDOoG1GaVd651tm5p2G0nE92k/P/9qIeKNzO551tY0zdNnlIW7kTE4OMnDCxw eHuIVspdTrH/SvqUNOaiqmYCN0+mSFe7XP23VT4zOrg8iy3HQr4VEfLHOw37NDLut8v8WnqLJ/S fdGKyGQZVtAAOfUggqtwxoMjHiN+6nlm3KNXtqmubbBvegSgmfeIApLaF4lE5pXNV3wH2ryUzI9 8KyUh/Ms0Dl5COSa1K7xmjYoYIB9L7tyMe7c3pi2ipHX9bG4uCrRtE4eQ2wutrejALoyPnRXaRs zHTyQ29C6xdbfErDqIZVPcIEM1NLYPSAqm8y9kZ0V1IdYRwzWFVBsvZVl9Cjl/cKpvINz4SDVS4 4 X-Received: by 2002:a17:902:8306:: with SMTP id bd6mr14762830plb.217.1544500296449; Mon, 10 Dec 2018 19:51:36 -0800 (PST) X-Received: by 2002:a17:902:8306:: with SMTP id bd6mr14762794plb.217.1544500295533; Mon, 10 Dec 2018 19:51:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544500295; cv=none; d=google.com; s=arc-20160816; b=JgyzJ6jM3DjLvTBI1XNmj7+loFJyoHoUquzg4tLpGKS/ol3msQaH8VFXtWTVDc09Dm HWEb4HrQKA1CZskRV/2CHZNKTjjuM/0bER9CmbtVqxWzB5JpWQunNEudV7Hj6obiXNG0 G7h2jFwZ7Qa+XekTswPoW6zErcULDXz+F7BYWF6DS40oJeoyYmwzPATyPyuzaX+V7z2T wqD5lXPwAHruy+xI+qqgEV78ijhA8BAcsUJx5MXW+zSjlUCZdqgItArPPSBYKoG9ki56 96ObKYFlFXbmHLx/5f/QDdpmKPCM2SFnmb/2Wy7ixBSrAK5nHjJy5haFCcoeDaUz4uN2 ZLzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=IVawOnQaWNEvgVWi+BphS0nrxrPkdnIoZUeATJdwRs8=; b=jtkuVSc8XlNWLQk0Is5z+SzPappy7ycRKeKYB6zp/SdDSY2IBuLkyAFqGOiNFYgXf+ 5L/WPhgFKm5/Xf5pTTOMDqLlOYH9W5dXEeTFSFnjbv3V4n7HDe8snTRjM3PI03+9LHW6 pZttim+c82OGVP5Ku9eKiemhPDJdbEJ7z1nSYjdRhidBmXJybEWXsNG7miAQt/A3HjNx +A0YXGtQ4wpAmNMHknXm3XcwKjJUEAW394NAG/ZA36BJSBYfVUwn/BXlsCgJubFL26OB s2aVYpFVxxz9Q10cpDsoN1Yh0mOBPoWbK8gRbHYt0PbGKCnhpGwFsKdkfn3iBBZPyRfT t7Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SRu89bgW; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x5sor19929557pgp.80.2018.12.10.19.51.35 for (Google Transport Security); Mon, 10 Dec 2018 19:51:35 -0800 (PST) Received-SPF: pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SRu89bgW; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=IVawOnQaWNEvgVWi+BphS0nrxrPkdnIoZUeATJdwRs8=; b=SRu89bgWp1gOMnsM9Xo5iCsXHDAVLFozWnfrAT887STxWg3BiXzU9tNt2+EwxHiwZv 98l/xpTdzO8S6S060tYLRnqMcDUnQXgV2iGbIGqLQK+CP8iETZ4G4uQZUfX4evOv9A1J WeGpKV6p1WDXGrcgs1G08cYlVxtxGKdVvDsvRfjwwccIrEprvFF1BNrLcAX/34UIdi6j HDYHp3FWmb4HFLGlGOqPs7u7Xg8Z5tbllPqKcaZNs4Vanb7m+KTmVdrp6NH8foa3CZ7t PT+CSeGq0NkbrZFilITC+qNeQmsx4iyNVmnXJhfcDj22XGKdfxCkPwq8LTpvAXa6J0/j 9SBQ== X-Google-Smtp-Source: AFSGD/XtVmC5auvgdha8bBI8wngcSxfnIeew8h5YRK4JFjlSRdkzpcH1uYJskhEIhH2NJkfReUMGrw== X-Received: by 2002:a63:c942:: with SMTP id y2mr13086003pgg.331.1544500294957; Mon, 10 Dec 2018 19:51:34 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id n186sm18424534pfn.137.2018.12.10.19.51.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 19:51:34 -0800 (PST) From: Wei Yang To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, mhocko@suse.com, osalvador@suse.de, Wei Yang Subject: [PATCH] mm, sparse: remove check with __highest_present_section_nr in for_each_present_section_nr() Date: Tue, 11 Dec 2018 11:51:28 +0800 Message-Id: <20181211035128.43256-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 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: X-Virus-Scanned: ClamAV using ClamSMTP A valid present section number is in [0, __highest_present_section_nr]. And the return value of next_present_section_nr() meets this requirement. This means it is not necessary to check it with __highest_present_section_nr again in for_each_present_section_nr(). Since we pass an unsigned long *section_nr* to for_each_present_section_nr(), we need to cast it to int before comparing. Signed-off-by: Wei Yang --- mm/sparse.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index a4fdbcb21514..9eaa8f98a3d2 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -197,8 +197,7 @@ static inline int next_present_section_nr(int section_nr) } #define for_each_present_section_nr(start, section_nr) \ for (section_nr = next_present_section_nr(start-1); \ - ((section_nr >= 0) && \ - (section_nr <= __highest_present_section_nr)); \ + (int)section_nr >= 0; \ section_nr = next_present_section_nr(section_nr)) static inline unsigned long first_present_section_nr(void)