Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1611039pxp; Thu, 17 Mar 2022 12:40:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgTiQdWMGN12R7xdHGMGF/M++UhQCg5dpZtqgJbgNPONHMCeGMV5+tmR5apog6qKcSymDD X-Received: by 2002:a65:63d6:0:b0:375:7cc6:2b63 with SMTP id n22-20020a6563d6000000b003757cc62b63mr4973378pgv.598.1647546028073; Thu, 17 Mar 2022 12:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647546028; cv=none; d=google.com; s=arc-20160816; b=rL/YYlMHv+taCHkLsvKMg49ofbwHfd/gJHaZ9jT+ChXIcyuPGpM2TVbHEhp/rbnkec fAkWTDnZcgnDVThh1hVqoPzEplTM+f1c5Vrq9JGmeNkT/bEA7IPue786JdTuaJrJ6kwv F9CaNW3g9+bByLRq8XmvJlXNP7n1znvCyu7yB/mIyXdChuAkf4rk4K6Hn/gqxt5PR0Ie 5Qe350mJJf4flp0QMZpJANS+MN8VQDJXCRD0cdZ0wTQcEK20UHPP3v22ELSeNGrk8g7S YhZ+BkScBS5nz3ZQjhlXbr5z9lT6GeZy7gjGTdmYdJXBlb5Htzb4ISeH7nKoq8YoErGm GkyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=lYwiG5bRLXTeHcV4+heyrtWSCIV19GNjQQjwTJEnpvw=; b=Nbd2gETFfRcZmphL4/WIVAqiM5kRUsVoIEzqTTFz6T/LBNfjVA5LaPMuPg0XDJWD00 XVQNFi5lvLD+nluQMPsdUBVpLQTvzOETRIUHufkyIX72E5bJufPME9c90JYfCNsHrhg6 DBlDo/hadRjfZCZgpkqv46TX7aYsnUB1SNErrB/ZvtOCs0IZEFs0aUSq6PSAr7Ta26n1 gH5D/6XUNxiIxkXIYsM8L/MHBisDd8ZgcYhtrC1O/MvnLvEiV5qBml6YGYthkf+GaW4X EEtw8NWruXQbHd40WmYOnxjW9G5PKvKAB9jGFL5+Z62IiQ5HNBSL45C1BqHvVtPKZNvS owjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id hk1-20020a17090b224100b001bf0205ffa3si3543209pjb.25.2022.03.17.12.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 12:40:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5822B223871; Thu, 17 Mar 2022 12:38:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235318AbiCQOnc (ORCPT + 99 others); Thu, 17 Mar 2022 10:43:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235407AbiCQOnJ (ORCPT ); Thu, 17 Mar 2022 10:43:09 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02C74200964 for ; Thu, 17 Mar 2022 07:41:53 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KK8q74JQPzcb6B; Thu, 17 Mar 2022 22:36:51 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 17 Mar 2022 22:41:50 +0800 From: Miaohe Lin To: CC: , , , , , , , Subject: [PATCH v2 06/11] mm/migration: use helper macro min in do_pages_stat Date: Fri, 18 Mar 2022 19:17:04 +0800 Message-ID: <20220318111709.60311-7-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220318111709.60311-1-linmiaohe@huawei.com> References: <20220318111709.60311-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_12_24, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Spam-Level: * We could use helper macro min to help set the chunk_nr to simplify the code. Signed-off-by: Miaohe Lin --- mm/migrate.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index eb1c736750da..92068d090db8 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1853,16 +1853,12 @@ static int do_pages_stat(struct mm_struct *mm, unsigned long nr_pages, const void __user * __user *pages, int __user *status) { -#define DO_PAGES_STAT_CHUNK_NR 16 +#define DO_PAGES_STAT_CHUNK_NR 16UL const void __user *chunk_pages[DO_PAGES_STAT_CHUNK_NR]; int chunk_status[DO_PAGES_STAT_CHUNK_NR]; while (nr_pages) { - unsigned long chunk_nr; - - chunk_nr = nr_pages; - if (chunk_nr > DO_PAGES_STAT_CHUNK_NR) - chunk_nr = DO_PAGES_STAT_CHUNK_NR; + unsigned long chunk_nr = min(nr_pages, DO_PAGES_STAT_CHUNK_NR); if (in_compat_syscall()) { if (get_compat_pages_array(chunk_pages, pages, -- 2.23.0