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 97273C3DA70 for ; Tue, 30 Jul 2024 18:03:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF1426B007B; Tue, 30 Jul 2024 14:03:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA1866B0082; Tue, 30 Jul 2024 14:03:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A69016B0083; Tue, 30 Jul 2024 14:03:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 87A456B007B for ; Tue, 30 Jul 2024 14:03:08 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1E6DC8041D for ; Tue, 30 Jul 2024 18:03:08 +0000 (UTC) X-FDA: 82397190456.12.FA4A8EB Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by imf02.hostedemail.com (Postfix) with ESMTP id B9E0C80017 for ; Tue, 30 Jul 2024 18:03:05 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=google header.b=bmnIwGxA; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf02.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.178 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722362541; a=rsa-sha256; cv=none; b=rW34jSNc9MrXSFJfSN5raTlnYpDlHQFtolc/OU9rdGrlAtbhsxv96s2DDPRwVU8UaVe9yj 1B/zDEhU82xgp2gXOBiTTD6mv7LNb1hxzFWsliIDdp7VvglzMIVabUf4ktcySl/2ggknI+ o11CHjyYU96gzUMiqAR09HSMNY+GEok= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=google header.b=bmnIwGxA; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf02.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.178 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722362541; 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=UjIcoWgZMymHKeItOzctBU0IZctaxNgeUikf+u5SGlA=; b=W987GAaH744HjMrOw78pDfbAX2ttNgAyv1tJS3w4R2bJ+7Uj3Z5GRJQUuD4hfyYHDJ+2am Aq78i33XEH0y3DxAEU9l+Pcuha5UN6R/TulqzEGJ7Gex5JZEXYo1xP3AHAvoCBvLK81kv5 x6OSU6yGYpux8Kt/eFNyd9/7d8TkZRE= Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2f0dfdc9e16so59882081fa.2 for ; Tue, 30 Jul 2024 11:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1722362583; x=1722967383; 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=UjIcoWgZMymHKeItOzctBU0IZctaxNgeUikf+u5SGlA=; b=bmnIwGxAx52q33cexRk4+BpLeD++0arLFHhfODaszCZnAuTKHrHRz34LKHeJmwHQsw WKb+dOqj6EvCfoYRp/iNHD05CYRc5mdzptERJKg7SXjaClD/uC8uMpDGg8DTy2g5I0yd 1Bh6YBSDwiMMklOSIJqFqr7526xPFCY25XstU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722362583; x=1722967383; 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=UjIcoWgZMymHKeItOzctBU0IZctaxNgeUikf+u5SGlA=; b=RdqEU68RPxEV4+l4/DJ4ohUDOICnJs1pWNU2cslayDRl3EECJPbMSI3CUBEkweu6jL fN026LPKHYxa0CYtEaGUFDYs3oHHbKWlxcky33U4j2eGmsy0Z+DkHIr8od7lAvnQAgb9 uvdBhxqZicILfHP7k+nOnRT/v3xcd8Msf82SQArUJzKRkc0grMFXHjNdQfuRLv9Cr11U bI0IPj1CERxQfsCawOWwFoSUYMJjuPVAp3vRVHz3v4MShRgHb6lOIFGCHdi8/PoRtQt+ 6fDXFB/+HrFOd1E4lrPDqmSQl5MwLr1WxA94Wh/gYjahzDTD5O/h+vDuO6ir2SSWJ0vv 9G0A== X-Forwarded-Encrypted: i=1; AJvYcCUGhcJ8NnQI/ZV18dJE2qSP3xECSJ9yhHr8lj6bUofYgkW/cB+AxQf76WLNm7tyn4kwfrJo36WxksYirtM3KnFMH8o= X-Gm-Message-State: AOJu0Ywo9Vr4WMaR375181PGNh6Rrp5UMNitfNZV0FI5KZtOYkcrTM2+ UGkwM5Q+XkX2cw5u1hxfoRpym7isyWyeQfgZ8H9NAXNUEBxXixiNkVMk03euik8QyrVjUUx0aTV 5zAW+wA== X-Google-Smtp-Source: AGHT+IFA+byhLb2ea02sVqj1xGR1UIdcDEWUTifOcN99xNL2NUYtcnvLfWbpqbnBAeusBD5rOrSnMA== X-Received: by 2002:a2e:a0d1:0:b0:2ef:2ef5:ae98 with SMTP id 38308e7fff4ca-2f12ee472bdmr72855231fa.34.1722362583476; Tue, 30 Jul 2024 11:03:03 -0700 (PDT) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com. [209.85.208.177]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2f03d04d784sm17598781fa.73.2024.07.30.11.03.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Jul 2024 11:03:01 -0700 (PDT) Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2eeb1051360so53306591fa.0 for ; Tue, 30 Jul 2024 11:03:01 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCUbmphyLkc6fG43bkwm7+e1d8PxBZIob6PggRmM+eSCjuaWnLsqJfPjkL05eReQFcVCtFfKm5piJVCIJAvTlnQIcT8= X-Received: by 2002:a05:651c:155:b0:2ef:2575:de11 with SMTP id 38308e7fff4ca-2f12ee0424fmr69853461fa.15.1722362581295; Tue, 30 Jul 2024 11:03:01 -0700 (PDT) MIME-Version: 1.0 References: <402c3c617c29465c898b1af55e3c6095@AcuMS.aculab.com> <5cd3e11780df40b0b771da5548966ebd@AcuMS.aculab.com> <8111159a-c571-4c71-b731-184af56b5cb1@app.fastmail.com> In-Reply-To: <8111159a-c571-4c71-b731-184af56b5cb1@app.fastmail.com> From: Linus Torvalds Date: Tue, 30 Jul 2024 11:02:44 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/8] minmax: Put all the clamp() definitions together To: Arnd Bergmann Cc: David Laight , "linux-kernel@vger.kernel.org" , Jens Axboe , Matthew Wilcox , Christoph Hellwig , Andrew Morton , Andy Shevchenko , Dan Carpenter , "Jason A . Donenfeld" , "pedro.falcato@gmail.com" , Mateusz Guzik , "linux-mm@kvack.org" , Lorenzo Stoakes Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B9E0C80017 X-Stat-Signature: x4i17tj5rsaw4q8czttgk76tsgt9149g X-Rspam-User: X-HE-Tag: 1722362585-375348 X-HE-Meta: U2FsdGVkX184JA0vid4/ZCsczqWShxq85/+0/Qyd5STvRISQalnY9YYrv7O3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twp47GP2TWFvomgOH7mHlCZ5X8aSmGAdTPTnAvXBlOeVtdCmwJe7VAK9j1BkEszYfHcpaIlgncFYPUw3n/+cjq7qpbBGycM8IQNb2lWHIQ5QYODxO1zHHmnRsYWEv7FomvcIjTcmFAFwJZSRWYKiTbUgHKG+j3VpIIw29alrEmmPncWhMBzTp6BmP9fEvGkt0voi1zH0j7t4KnzVFrRcyzALVNsTmwHUx0O4u0SOCpPPpH1Pjse3tyMsPAeSw1WKgSsl8ChBTXvmFraZAfPd9dExMwlLxSfLNbTsdHuB/ua6CyAiNdYpbwGqprPKmZ0Nr1SbIgDgbzFom8dDC29wRWlC8pZxM= 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 Tue, 30 Jul 2024 at 07:15, Arnd Bergmann wrote: > > There is another one that I see with gcc-8 randconfigs (arm64): So I ended up undoing that part of my patch, so it's a non-issue, but I wanted to figure out what went wrong. It's actually quite funny. > net/netfilter/ipvs/ip_vs_conn.c:1498:8: note: in expansion of macro 'clamp' > 1498 | max = clamp(max, min, max_avail); So it turns out that min is seen by the compiler to be constant (8). And max_avail() uses order_base_2(), which expands to this huge comparison table for the constant case. Now, in the end all of those comparisons will go away, but I think what happens is that because they exist at the source level, the compiler ends up expanding them, and then - for exactly the same reason as before - the compiler can find a path in that tree of conditionals where "max_avail" does indeed end up being a constant smaller than 8. The fact that that path is then never taken, and pruned away later, doesn't help us, and the compiletime_assert happens because in one intermediate form the compiler had folded the now trivial 'clamp()' of two constants in with the conditionals that get thrown away, and the warning happens even when it's not reachable. Anyway, it does mean that yeah, the much more stupid static_assert() that will never try to follow any chain of expressions si the way to go. For the type checking, this isn't as much of an issue. The whole "is that a non-negative expression" also uses the same machinery, but if the expression could be negative in some situation (that goes away in the end) at worst it just means that the new rules won't be as relaxed as they could be when the expressions get sufficiently complicated. Linus