From nobody Tue Feb 11 05:15:52 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YsV5l2LxNz5mx02; Tue, 11 Feb 2025 05:15:55 +0000 (UTC) (envelope-from unkadoug@gmail.com) Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YsV5l0Rvwz3FQF; Tue, 11 Feb 2025 05:15:54 +0000 (UTC) (envelope-from unkadoug@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3f314ff6ffdso2984991b6e.0; Mon, 10 Feb 2025 21:15:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739250954; x=1739855754; darn=freebsd.org; h=content-transfer-encoding:in-reply-to:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=h3+nqeQfebaXApwoP9/me3OuLHzEteIkBYzhR5x9kJo=; b=ROVejfwsSEaTeD4xLTPmo0PsGnXUVTyH8K9mcr1ny5BjHLR+emBiNxiozQBxqaZbzC eVLlQ34zSMOs/3BKnVZkw8GuHJbEKcV3d6a+5u/8br9r5tLKavV7Cnt/oCWhCYVPZnLd +Kk8uQEQOBVRGFnNDlsiTDti+fuomIRfNpH0cA5IkxmAcibOWv4yejWEFmHkXVsKn8UX zzUGnAvxd9DzQt4D9TgO1Uaql6Qd24Ut6wad4jos581a1hnqT3HWJBFqS53eWexB8UPw 2ZLJD9S+RGWeSu8SfCC0qkMdyy/N//+v14nmXKiuDW2cmh5Xra0L3knJJNHhdaVTDfYA iJ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739250954; x=1739855754; h=content-transfer-encoding:in-reply-to:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h3+nqeQfebaXApwoP9/me3OuLHzEteIkBYzhR5x9kJo=; b=strD7Q0vYST7oOB4JsxjFWlk86FL2fAJYH1zpVPlOQdDA945wZQYubyeQ6ZaXglKDm 7UlPV9wKIZTK76unYNB3RfvMH/jx6iJs9WHfFfVTICIx2F81Hmhlixp1jpL5ysScB9Pp jhJJnwnYSeziycCq7MT6AanBFti5c9oDf2SCsuyGQYus/nqlL+kV8eVCVCzCv8b6VAXv j+5y8uTO1knOWtzWXpCr51hH65ayElqhFkE3Z9tc6d+dBiIQs8uWZtLcs42vdOxgy/c7 TMeyXz807FHT2aq0UcQlb7DLcQMfU2DJIqthF/xXb0zCqGYXtjy1fxGQHtOTEYA5HJHh IkaA== X-Forwarded-Encrypted: i=1; AJvYcCW4L35NAz15XuLywxZYhRGPq/HBiqr8RX8THh3ZiOlLD7sO6ArYnH3w8esZIG0leYp27g==@freebsd.org, AJvYcCWt4Yq7DLLuGN6bDbMWPY1Z9V1mUO0hYxH92B3t+8TJ3/iULoaf4wZGWKTlm5KmFtqA+AJEIYIFDOJtatK+3e5ns6GDIA==@freebsd.org, AJvYcCWtYkTuxpExpr25grS955L6D1ybIA1Fzb0YV6+nfab9BrfDAELN+YyK/WPmNRWSjofJZj7L5Ze5s5hCW44mLwVoeB/8YEkDhnKK@freebsd.org X-Gm-Message-State: AOJu0YzRfi90G7Ofp1f6NHPwvDHonQNHYCrAq00CDv7804FdgzvL2a08 WTDNVQtNcFlbTRi81dSLbbj8I0BCmq0nsqJbtUzLsFPVA1Pl6ZhTyxlcxdDD X-Gm-Gg: ASbGncuRpOx/fDA/coXEfVFyhk6tNIAExy74D3wNr+GyZejwbmKgDXvtZvvaGGKNeJ0 kaG8f5FNv7TsrQd2GgdMtM2G5+Scfcxqte15Dp/psfijjvTvyDaVKiFuzqV7BRucOI9uQIRn5JW zfidN5ylrTK2OII2mEhqCHjW5R38Gz8pqjdZG+G10Ml7biL55jt9YjZzJA9fxwga1myk5uBEX3j fpOVPKY9T/aNjJLgqmnzTvD8HEpxsOG2i6bYYvjTcO4pW6+6XM0FcLCOZdNulLvaiYEpWpRIXXp PbilfYZNwRIr3UrYIdmpD+/ECuAA+pxiHfvkT7bS/jzaz4gHlDb3BqC49BKf3QNNW1Kd6mof4Q= = X-Google-Smtp-Source: AGHT+IHo0TpzJ4GDZbqTqHF/n98C4H/JPZ9GMjhNOYrY2uzyRjGDSD8Tu+VsYZGrySjwIf58r4fKXQ== X-Received: by 2002:a05:6808:3505:b0:3ea:64cc:4954 with SMTP id 5614622812f47-3f392363e82mr12249275b6e.35.1739250953639; Mon, 10 Feb 2025 21:15:53 -0800 (PST) Received: from [108.254.203.202] (108-254-203-202.lightspeed.hstntx.sbcglobal.net. [108.254.203.202]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3f3a5a74dc5sm1604478b6e.29.2025.02.10.21.15.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Feb 2025 21:15:53 -0800 (PST) From: Doug Moore X-Google-Original-From: Doug Moore Message-ID: Date: Mon, 10 Feb 2025 23:15:52 -0600 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: git: 7bcc7a0b88cc - stable/14 - libkern: avoid local var in order_base_2() Content-Language: en-US To: Zhenlei Huang Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-branches@freebsd.org" , "Bjoern A. Zeeb" References: <202502101115.51ABFISj016298@gitrepo.freebsd.org> <858BD10B-A2C9-4D3A-9FF5-C5573597DF8B@FreeBSD.org> In-Reply-To: <858BD10B-A2C9-4D3A-9FF5-C5573597DF8B@FreeBSD.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4YsV5l0Rvwz3FQF X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] bz@freebsd.org presented the problem that this change fixed.  I think it was in a driver.  It may have been a case in which the macro argument had side effects, and having it appear twice in the macro made those side effects happen twice.  But I have not preserved the original report from bz.  I regret that I did not adequately describe the problem being fixed in the commit message.  Perhaps bz can shed some light on the matter. Doug On 2/10/25 21:30, Zhenlei Huang wrote: > >> On Feb 10, 2025, at 7:15 PM, Doug Moore wrote: >> >> The branch stable/14 has been updated by dougm: >> >> URL: https://cgit.FreeBSD.org/src/commit/?id=7bcc7a0b88ccb5e1fe31de88ab9a17e46859318b >> >> commit 7bcc7a0b88ccb5e1fe31de88ab9a17e46859318b >> Author: Doug Moore >> AuthorDate: 2024-09-27 23:43:07 +0000 >> Commit: Doug Moore >> CommitDate: 2025-02-10 10:30:05 +0000 >> >> libkern: avoid local var in order_base_2() >> >> order_base_2(n) is implemented with a variable, which keeps it from >> being used at file scope. Implement it instead as ilog2(2*n-1), which >> produces a different result when 2*n overflows, which appears unlikely >> in practice. >> >> Reviewed by: bz >> Differential Revision: https://reviews.freebsd.org/D46826 >> >> (cherry picked from commit b7cbf741d55468ba34305a14ac3acc1c286af034) >> --- >> sys/sys/libkern.h | 5 +---- >> 1 file changed, 1 insertion(+), 4 deletions(-) >> >> diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h >> index a10289d72dc7..835e5ffaf0b7 100644 >> --- a/sys/sys/libkern.h >> +++ b/sys/sys/libkern.h >> @@ -229,10 +229,7 @@ ilog2_long_long(long long n) >> >> #define ilog2(n) (__builtin_constant_p(n) ? ilog2_const(n) : ilog2_var(n)) >> #define rounddown_pow_of_two(n) ((__typeof(n))1 << ilog2(n)) >> -#define order_base_2(n) ({ \ >> - __typeof(n) _n = (n); \ > This local var `_n` is within the scope of the macro `order_base_2`, it is surrounded with > {} and is harmless, so it will not pollute the file scoped variables. > > Am I reading the commit message wrong ? > > Best regards, > Zhenlei > >> - _n == 1 ? 0 : 1 + ilog2(_n - 1); \ >> -}) >> +#define order_base_2(n) ilog2(2*(n)-1) >> #define roundup_pow_of_two(n) ((__typeof(n))1 << order_base_2(n)) >> >> #define bitcount64(x) __bitcount64((uint64_t)(x)) > >