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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE2E2C02199 for ; Sat, 8 Feb 2025 03:11:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 36229280004; Fri, 7 Feb 2025 22:11:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3138D280001; Fri, 7 Feb 2025 22:11:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D9FF280004; Fri, 7 Feb 2025 22:11:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 01924280001 for ; Fri, 7 Feb 2025 22:11:30 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 96DE214155C for ; Sat, 8 Feb 2025 03:11:30 +0000 (UTC) X-FDA: 83095301940.03.1C0B3E0 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) by imf07.hostedemail.com (Postfix) with ESMTP id 7B70B40002 for ; Sat, 8 Feb 2025 03:11:28 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=THLx3om+; spf=pass (imf07.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.46 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738984288; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FOVpMJcaokY85KzmVoacEr/X/dlAvwuwsIku8cwRQIA=; b=JeZuzsNDc3Afd4LP8cPUxEWOi01jhWkDunKBM0snTSCGc71bXEOttWcjBKw/TPCu6XRfgL CI6ByPW1MQhsJ6KkBXngoXHOYtlTi7rdht3Ie9m4xaMJXY9q/Pvbrqdsxm/X2QAvtAX2ow 2U+7Ws4b3BaiIh2lwGe3XwTtvbsW8Ik= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=THLx3om+; spf=pass (imf07.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.46 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738984288; a=rsa-sha256; cv=none; b=g2lSZmrX74bpXANY5tONJO061HpGjUifj2f6OeAmoluKSSl4l1XAxAfMhiHNn4s0Cjktgx XKVIgsiiRhJLCfbaxcg0+7Nlxvlp55HAvZ13bmmkiAepu8uWpx87IPwDRTSjlbv1Nm4AUN PxzSqDeim8OaR/8mNuEQvf1BM8S6M7Q= Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-5de4d3bbc76so1960716a12.3 for ; Fri, 07 Feb 2025 19:11:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1738984287; x=1739589087; darn=kvack.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=FOVpMJcaokY85KzmVoacEr/X/dlAvwuwsIku8cwRQIA=; b=THLx3om+QEKpUbsq/5dYDUpwAip0Hw5ctLqWGWpD6ca4/akdYGY00+9+vgl4w881go BGybaQiIlO7d8Ub7Op7CEsHm0ZmLTQO0JW3Yo/Iaa+UJ3GMOXMOeUuwblZAwNDNN1b5K 4piV+VYQsdpLs5PL5m4eGars8za/7GmZVepaY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738984287; x=1739589087; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FOVpMJcaokY85KzmVoacEr/X/dlAvwuwsIku8cwRQIA=; b=QrkYBjHYmSwJMRQGZKJcDpgIf2vRXKNEOdckDiM8soEEX5i85AWqwtD1EJJq4++rMN LDs7EuR7FUEiH+kwAdck3MiIUs0BiHXsm00KgZG38KJ7GkbFZaVAbY0lrijyYMqgPPfm ie0ybkuVtJVSUtKqfvPAK4hNtMRMRoEYhzhl/P3DazggGe6MwPLgF24e4TzmB9PJ3Zvi Y6QnHCqWWac49cya0tktzQPYC8IntT/ow547k45YVcUJxSimCvLC7puV99A3wFbGfEdv qy3oMX64e0+iw0OEhkLXSlgah5AsE7gJF54AjAxa3GwHWo3HNwEQGDftTanvq/KqkU0H zDsw== X-Forwarded-Encrypted: i=1; AJvYcCXw78ScnvtK4XrHhsmjPanc6HDNczYLelZ43jsy1nYL3e3aZBaRvd0N7NTVcM7IgK/3kC8hTpd53Q==@kvack.org X-Gm-Message-State: AOJu0YyoJTZotToUwB1n371fNHp146b962zNmeGjqpdyEvpFY3Ujzn+X qeIgR2deA0FdOv37Okm3G4RQ51SBnfqZzSCPmHdK1+vhKmbncfYsxR1wOskxY2M1o2pN/9YQvQu 79Pg= X-Gm-Gg: ASbGncuybohsqeL3ODoqhkavDrfyos9qTCW6HGsyLW0EyuFFoapD+xHFtbjp3n9YOPM zrLUqs5PdQbiBzxJ7SaFbobfpAqRjNvbNXchVinhMTXtACku1Q1TeWN++J53zVMSWojq2nWdbQ3 DMqH2z/ri9R+BxXNteRGmn0gKEs/8VShzU7d/4RiwjQj5kW9X3aI0W70Jenb/KY3CJcYVwCBLIW TNRTnRYUYKDzR2JEJdd29b4yBs+v0XAg9rFtDwOrME5EnfJRfAI+gECO82tDUQKmp0pVps3tVVq BvJw6X3KKp82PJ5y+rX1kQXhMu6AnQ+/cpADX0/jMnGffQYSS5dqRYWhelVaviy7xw== X-Google-Smtp-Source: AGHT+IGvOtmKThgH0AqWgKJ+/tw8O6iBd7kmE4rAMHLAgVhFM/HQUNnQ+EEY19zDAW9Ory03u4UurA== X-Received: by 2002:a05:6402:2106:b0:5db:e7eb:1b3a with SMTP id 4fb4d7f45d1cf-5de450048a8mr6159250a12.10.1738984286399; Fri, 07 Feb 2025 19:11:26 -0800 (PST) Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com. [209.85.208.44]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5de52712538sm1247235a12.49.2025.02.07.19.11.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Feb 2025 19:11:25 -0800 (PST) Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5de4d3bbc76so1960669a12.3 for ; Fri, 07 Feb 2025 19:11:24 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXZfKmLCkZmvX/uGukfXL4ZiM5v3JwOgKuYuicSOfDqOkSC+a5NDLmA7oqlwllqikhv28EWiDghaw==@kvack.org X-Received: by 2002:a05:6402:5290:b0:5cf:e9d6:cc8a with SMTP id 4fb4d7f45d1cf-5de4507350emr5770026a12.20.1738984284318; Fri, 07 Feb 2025 19:11:24 -0800 (PST) MIME-Version: 1.0 References: <20250131191231.1370466-1-bvanassche@acm.org> <20250207164926.6daeac77@kernel.org> <20250207173813.5081ba76@kernel.org> In-Reply-To: <20250207173813.5081ba76@kernel.org> From: Linus Torvalds Date: Fri, 7 Feb 2025 19:11:08 -0800 X-Gmail-Original-Message-ID: X-Gm-Features: AWEUYZlJV8s382PdRaDNGK_s-_jZj-Ua17NllqtZGBqSsW7wCeFl2fZwSDs96W8 Message-ID: Subject: Re: [PATCH] mm: Fix clang W=1 compiler warnings To: Jakub Kicinski Cc: Andrew Morton , Bart Van Assche , linux-mm@kvack.org, Ivan Shapovalov , Vlastimil Babka , David Laight , Nathan Chancellor , Pasha Tatashin , David Rientjes , David Hildenbrand , Kaiyang Zhao , Joel Granados , Sourav Panda , Johannes Weiner , llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 7B70B40002 X-Stat-Signature: h38qakej4t7zwwdhbs1a9ih4nf344un8 X-HE-Tag: 1738984288-356422 X-HE-Meta: U2FsdGVkX1+hFZPPyjWJkIDkkcLBcqrQFR6+ffFakdg965UBdahjC+0BBp9T4w0pC9U3HW/tmlhLiw58znBnx4bYMzJRP/Rf0ntDYSQ86212AtDH8kUCkJ6Fe45nu4yZwU/0lvCrKrWobPXZ1n7sSgZkxGZuNJFEMHVlRKHxIsfmSD7v9dHCl7+ymaDHDlnFpUBEYp3eS+vhbmAvxO607dGo5S4ghfYq+fWwy/LAT/RUPmhjH4ANodLExRCXZVEHrK2coAC2At/qN+f/5b7SCG9nuej8XNwPg8SQoVxT3XXb3QE9xCRyjq3q5xsBfP6CTWBy7Hid2moyTeqx9jdRWGzeDpQTh3tj81X1FmJQfJluA06mHtFT61hXT4pCA8Xs/N9XX2ai0yE5+CYbmkxZBKdOcPrKPg1QKEPtDBm50tus+6fBXCq/ia92LLQBX0l/mpp1DvD50dG3iEcImUbF853G9BZs5EVB33zDLOvmE/qwy+iuXIzeDIz/c8GE/bpdBX1e7/JFsAc4vV/H+35ap2z8QnWnTQziUGl7aPBlCM3PjMSNGFOvj3dT6wguemJGeSBCKjZNbqGLovcAIoZ03t5osqIC/IDSTxVyzoEyIDjPNgb0wL2FoSct8AoujVcanoEFwn3RZzZmRH+Yne8f9a1gR1Tc2FblGNYNpIIUv6Zh49nS+pi1a7f1GMc6D8cXjRdSXVkAUCIJ4pcQ2DzbQSKCNQ4qqYOYdCEeGpazVeIwAE3bjwtZDT1KyfjPhO8q0QCyH7QorJJqjAmKYxZ8fetU9MZs7ENWFVIxe5x+yaTUPCGqz0NYs57o4fJgG/Ta3GU9xMzgx+ZWUdOzzQcxkI0ewrruOT7n/dsb2eC2jW/dU5CM/wC9qGygBM7o6uKW8p/MIqRWG5FkrxiNmAvEAqNIAc+pACffTgrXnJfpJ8OroHyX9DaiyQwtroSY3g64eejpQB8UOmJaGjw7OkM JHy4b9sf mAFD9wImCMldly2EMCf3LAgD5iuQRjm6n3Mwy303t1a7qVz8YYPy4ZD7PVPE0djBCHuJouo3VuGOwsH6bQDbu8E7tzJ/HTZjpe8OMwawCAsyAoqNnsCLEy1fNfkkz8vfCHAKx9JI1H4UUc6IYeyHe8cPPUNrbK2Cdpgn5xruUH8iLSqf6kPSKZGp0HaXjRJPi91vZxyfPprPa/35z+zOAYdMclTlU1VVZZyt8Dg1UubaG0ufuEQrhj0jGIuW+De+ps5JecT4sIebbCQLVfGKISo5BJD9y72g++E+47LQ7MQ0h1Z8fnl1vOmm74moIgWGq/93IIoJWRyJXQAXvOAEfx/bcr6NEyPWmscSnG3DLJvc8r1RMB2xSVDhQ/9DcB7wdE3cbZqDxz4m+HZewUD4vVbxQEtpmhfIV1uzn+Z/tAQZN7osElE3djt794jAOKRMzGdLGdzAMTZIHfi5RXInSMMfxRHaHt0MBqzkCrov7gz6O/PXUJTm+A+82iTuC07aSj6nfyPXdObLiZcGf2MUU4rnzCw== 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: List-Subscribe: List-Unsubscribe: On Fri, 7 Feb 2025 at 17:38, Jakub Kicinski wrote: > > ../include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion] Ok. So my gut feel is that this warning is simply bogus. We have situations where we very intentionally use enumerations instead of a list of #define constants. That NR_VM_ZONE_STAT_ITEMS case really *does* look like it's a great example of how code that doesn't care about the actual numbers, and just wants the compiler to generate a sequence for us is supposed to look. Because sometimes we do enums just because it's a nice way to get automatically incrementing values when we don't care exactly what the values are. And sometimes we do it for actual namespace reasons - see for example commit 1a251f52cfdc ("minmax: make generic MIN() and MAX() macros available everywhere") where in order to avoid clashes with the "MIN()" macro, I made a couple of drivers that had a 'MIN' value (much too generic a name, but it was what it was) use an enum instead. See git show 1a251f52cfdc drivers/hwmon/adt7475.c for details. Now, at least in that case I don't think there was any arithmetic with those values, so clang-19 wouldn't complain about it either, but I mention that commit as a case of "it's actually very valid to use an enum for actual real honest-to-goodness integer value enumeration". Which really makes me feel like the new clang warning is seriously misguided. In sparse I actually wanted to have integer types that don't silently cast to other integer types. So sparse knows the concept of "bitwise" and "nocast" attributes. The "nocast" thing doesn't work well in practice, but "bitwise" was a huge success and is how a lot of our endianness problems were solved. So the *concept* of an enum - or any other integer type - that "stays in the type" is good, but I think it's a major mistake to think they have to do so without any sane escape, and to only limit it to enums. That said, we may not have *many* of those enum cases in the kernel (and we do tend to have a history of using long series of '#define' sequences to do these constants), so maybe the warning is acceptable if it's a case of "this is literally the *only* one in the kernel". But not having clang-19, I can't see if this is a case of "this is so rare that let's just avoid it", or "this is the case that causes the most noise for every file build, but there are lots of other cases of this". Linus