Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4052587ioo; Wed, 25 May 2022 13:50:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKaZCzl1meCNlZOQddH6pyuy1iVytxIWfV1b1Ns5zRY5VDBTEyRPiaxBS/IoIlVYl9Z8kH X-Received: by 2002:a05:6402:354f:b0:42b:6da9:ed5a with SMTP id f15-20020a056402354f00b0042b6da9ed5amr16819683edd.148.1653511845927; Wed, 25 May 2022 13:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653511845; cv=none; d=google.com; s=arc-20160816; b=qStWI40fw35vXnsnHpRZloSFcHQa6qHlmycQ7AwH+QIniqnzKgBZGHczV81WdzNqvQ 62LjI3vM4sS/1im13rUI50iE/Qa1hyqTFKkvrINlrwKihRQF0yvb2VoCpHzyt8bls2m/ Z1rJ5Yr9JbnZQ0SgGOZKx3CLHAXmJgP6FptP75Xsetp3uGXaPU4pELixry9nG6c6Drkv 0iWYYIUhaZYhu3U8qDOgV8pfXbdd8jy80S9ukxGSvs1qIobKybcwvUZ7tt5KtJ5Y7OVl 2Hy/gpBRUo1uqw44ne5SeXr5c1cex4SYRcFCwQnSTniXfZpR69RbOqOOqycv8EftOWap SO6A== 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:subject:cc:to:from:date :dkim-signature; bh=YyQRKVhNxn6Yk+UyJwmTXez/b+u1aDJzRRRXJThsb2A=; b=ASAEKNMRiKHsJsygnS+lqA5KV5FkVVCfxNvpsa9h9hzG2v7NCqKXabThWvAIztv70I CCmMq0uJ1EuAcfa17FyekpXfPwW6CUTRch4SeF8Kl5HnOaqgfGgF5gPdk4jD1N4xa0iI N+opM/Op1GRSW1p3gp7SvZVBObDKDRCSNH2Tno6qJBQMiabYJp7MS4oZ/L1pPqvTXBaL gtO1d9fKMh7PbliZj5dc4F2OItML8aUXHGm0+3WtW5Er8nmII4wUIeA7uwxp+olpwZf3 R6eShVgnQ3/zB10rkYLbX0mFHwBkYDdHDAseDAje2LRtKssEMtEBh6CisjrS0CalgGVM zUKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=SkatBIHR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du4-20020a17090772c400b006f4ab13f1desi24477118ejc.122.2022.05.25.13.48.35; Wed, 25 May 2022 13:50:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=SkatBIHR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245700AbiEYRg1 (ORCPT + 99 others); Wed, 25 May 2022 13:36:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235031AbiEYRg0 (ORCPT ); Wed, 25 May 2022 13:36:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B752AF1EA; Wed, 25 May 2022 10:36:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C5F88B81D03; Wed, 25 May 2022 17:36:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E799C385B8; Wed, 25 May 2022 17:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1653500182; bh=2sZOK+u8TWT2hz1WpVc/08X2wVHPW+B9FaWItdMS6eM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=SkatBIHRITw6zvVX4YnXKdYK0+EGDe+CSZbCe0jc738X2QM9B/iUCZq+wM7v3dTlQ 0PtF0mEjA0iXlCWrMv2ewqUOx7TlJXRMWCT9B9JUhbm6FlvH2Pcyy8Vb1PvY/xcYq4 xkSOXG1qbRnW6xSDTrlgCJ7U+pIwhqCLyZj4NoRk= Date: Wed, 25 May 2022 10:36:21 -0700 From: Andrew Morton To: Zi Yan Cc: Stephen Rothwell , Linux Kernel Mailing List , Linux Next Mailing List Subject: Re: linux-next: build warning after merge of the mm tree Message-Id: <20220525103621.987185e2ca0079f7b97b856d@linux-foundation.org> In-Reply-To: <6CA81704-417D-4843-940E-F901803A908C@nvidia.com> References: <20220525155401.4a72ad6b@canb.auug.org.au> <6CA81704-417D-4843-940E-F901803A908C@nvidia.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Wed, 25 May 2022 06:57:53 -0400 Zi Yan wrote: > On 25 May 2022, at 1:54, Stephen Rothwell wrote: > > > Hi all, > > > > After merging the mm tree, today's linux-next build (sparc64 defconfig) > > produced this warning: > > > > In file included from include/linux/kernel.h:26, > > from include/linux/cpumask.h:10, > > from include/linux/smp.h:13, > > from include/linux/lockdep.h:14, > > from include/linux/spinlock.h:62, > > from include/linux/mmzone.h:8, > > from include/linux/gfp.h:6, > > from include/linux/mm.h:7, > > from mm/page_alloc.c:19: > > mm/page_alloc.c: In function 'split_free_page': > > include/linux/minmax.h:20:35: warning: comparison of distinct pointer types lacks a cast > > 20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) > > | ^~ > > include/linux/minmax.h:26:18: note: in expansion of macro '__typecheck' > > 26 | (__typecheck(x, y) && __no_side_effects(x, y)) > > | ^~~~~~~~~~~ > > include/linux/minmax.h:36:31: note: in expansion of macro '__safe_cmp' > > 36 | __builtin_choose_expr(__safe_cmp(x, y), \ > > | ^~~~~~~~~~ > > include/linux/minmax.h:45:25: note: in expansion of macro '__careful_cmp' > > 45 | #define min(x, y) __careful_cmp(x, y, <) > > | ^~~~~~~~~~~~~ > > mm/page_alloc.c:1138:35: note: in expansion of macro 'min' > > 1138 | free_page_order = min(pfn ? __ffs(pfn) : order, __fls(split_pfn_offset)); > > | ^~~ > > > > Introduced by commit > > > > 29a8af92b874 ("mm: fix a potential infinite loop in start_isolate_page_range()") > The min() warning says "we screwed up the types", and reexamination is in order. > The patch below should fix it: > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 6eec0211e0be..dbbfe4a079d3 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -1123,7 +1123,9 @@ void split_free_page(struct page *free_page, > pfn < free_page_pfn + (1UL << order);) { > int mt = get_pfnblock_migratetype(pfn_to_page(pfn), pfn); > > - free_page_order = min(pfn ? __ffs(pfn) : order, __fls(split_pfn_offset)); > + free_page_order = min_t(unsigned long, > + pfn ? __ffs(pfn) : order, > + __fls(split_pfn_offset)); > __free_one_page(pfn_to_page(pfn), pfn, zone, free_page_order, > mt, FPI_NONE); > pfn += 1UL << free_page_order; `order' has type `int'. Inappropriately signed. It should have been `unsigned int'. Too late (or too large) to make that change. __ffs() and __fls() return `unsigned long'. Inappropriately wide. Should have returned `unsigned int'. Too late (or too large) to change. So we get to live with the mess we made. Your proposed change adds more inappropriateness - why cast to ulong when assigning to an int? --- a/mm/page_alloc.c~mm-fix-a-potential-infinite-loop-in-start_isolate_page_range-fix +++ a/mm/page_alloc.c @@ -1123,7 +1123,9 @@ void split_free_page(struct page *free_p pfn < free_page_pfn + (1UL << order);) { int mt = get_pfnblock_migratetype(pfn_to_page(pfn), pfn); - free_page_order = min(pfn ? __ffs(pfn) : order, __fls(split_pfn_offset)); + free_page_order = min_t(int, + pfn ? __ffs(pfn) : order, + __fls(split_pfn_offset)); __free_one_page(pfn_to_page(pfn), pfn, zone, free_page_order, mt, FPI_NONE); pfn += 1UL << free_page_order; _