From nobody Sun May 21 17:05:41 2023 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 4QPRmf5DxXz4CDdD for ; Sun, 21 May 2023 17:05:54 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QPRmf3dCgz3kd8 for ; Sun, 21 May 2023 17:05:54 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-3f601c57d8dso4266405e9.0 for ; Sun, 21 May 2023 10:05:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684688753; x=1687280753; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TiuRDeY/h11Wq/e90Q1jR5uaJRGfj/tTX1GTmYZDpzY=; b=koGQ9sj+MwfT0g528oRjiVCJ2bZoIAIseUFEb4qeZvH2ic9bC9lYXc8RW4cprpIcJz TzRMaODbrCGDxqeagNgNiHfnrkfUESA7w2QUj/2rpE6QX41oCxidLnql7p5za4mSAeM9 GO2+eJn9sTf9TKh2nZSJ77WaBpeXBwZyEgubfK+mDMCHvSg1W+/BGy+O1NiDSsfKJJD9 7TcCR4ALCR/tyaN44TQYPG/PkMBcKf0OKiCx7x/ykSEft0ZSSgVIcopKiF1g+unFFPWp 0zruCadyYEEb3S38/XksxW02Pz2g3Dtd5R4PVGhC9eK45JTAlq7s6KmHWJfA225KP89G CTEg== X-Gm-Message-State: AC+VfDzJCYAznZai/emSZA3g2lANFvVW0MqXUMAa0/KxES884O2Rmtv7 LzfprLO0IkaDWDMfGFt4lHcpUQ== X-Google-Smtp-Source: ACHHUZ4zsOuN8IATqQWFKrX5vLfbkwhinaZxwf3ao7Fhm2jj3sBh/Cg1EiX2NeMMCnbB5Qa/ZO64TQ== X-Received: by 2002:a1c:790b:0:b0:3f6:1ac:5feb with SMTP id l11-20020a1c790b000000b003f601ac5febmr1793005wme.16.1684688752905; Sun, 21 May 2023 10:05:52 -0700 (PDT) Received: from smtpclient.apple ([131.111.5.246]) by smtp.gmail.com with ESMTPSA id l22-20020a7bc356000000b003f1751016desm5672024wmj.28.2023.05.21.10.05.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 May 2023 10:05:52 -0700 (PDT) Content-Type: text/plain; charset=utf-8 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) Subject: Re: git: 805d759338a2 - main - mlx4: Move DEFINE_MUTEX() outside function body. From: Jessica Clarke In-Reply-To: <21c9532e-4ca7-a7fe-1ff6-07a94cbad6ab@freebsd.org> Date: Sun, 21 May 2023 18:05:41 +0100 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <3066464F-E4C6-4B84-ADFF-E578AFAFE622@freebsd.org> References: <202305211621.34LGLsup059861@gitrepo.freebsd.org> <54EF67D8-2A79-4EAB-8EFB-232F14FFE792@freebsd.org> <21c9532e-4ca7-a7fe-1ff6-07a94cbad6ab@freebsd.org> To: Hans Petter Selasky X-Mailer: Apple Mail (2.3731.500.231) X-Rspamd-Queue-Id: 4QPRmf3dCgz3kd8 X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On 21 May 2023, at 17:57, Hans Petter Selasky = wrote: >=20 > On 5/21/23 18:33, Jessica Clarke wrote: >> On 21 May 2023, at 17:21, Hans Petter Selasky = wrote: >>>=20 >>> The branch main has been updated by hselasky: >>>=20 >>> URL: = https://cgit.FreeBSD.org/src/commit/?id=3D805d759338a2be939fffc8bf3f25cfaa= b981a9be >>>=20 >>> commit 805d759338a2be939fffc8bf3f25cfaab981a9be >>> Author: Hans Petter Selasky >>> AuthorDate: 2023-05-21 11:25:28 +0000 >>> Commit: Hans Petter Selasky >>> CommitDate: 2023-05-21 16:20:16 +0000 >>>=20 >>> mlx4: Move DEFINE_MUTEX() outside function body. >>>=20 >>> Move static mutex declaration outside function body, to avoid = global >>> variables being declared on the stack, when using SYSINITs. >> What? This is nonsense. It=E2=80=99s not on the stack either way = round. >> Please revert this. >> Jess >=20 > Hi Jess, >=20 > I think this is a false positive of yours. You need to look through = all the macros used there. No it=E2=80=99s not. All the definitions are static. > Basically DEFINE_MUTEX() expands to a bunch of structures, which are = not in any block. They are all static. > The "static" you see in patch just covers the first mutex structure. Because only the first one is ever not static. The rest always are. > SYSINITs use "static" in front of all structure definitions. Exactly. > If you want to change from static structures to global symbols, then = my change is correct. Which will bloat symbol tables excessively. But you didn=E2=80=99t state = this as your goal, you stated it as a behavioural change *today*, which = it=E2=80=99s not (other than changing the scope). Your commit message = was entirely nonsense, and so I told you that. If your goal is instead = to allow for future changes, put that in your commit message. I am not a = mind reader, nor is anyone else. It is extremely unhelpful to have = commits that say one thing but intend to achieve a different thing. > Before: >=20 > static DEFINE_MUTEX(xxx); >=20 > Expands to something like: >=20 > static struct yyy xxx; static struct sysinit zzz; .... >=20 >=20 >=20 > If you want to change from "static struct sysinit zzz;" to "extern = struct sysinit zzz" and also initialize the structure there, then that = won't work, based on what I currently know about C-programming. I tried, = but clang gave me a warning about it. Clearly trying to define a variable with global scope at function scope = isn=E2=80=99t going to work, yes. > You can't declare global variables inside a function or it is not good = style. >=20 >=20 >=20 > =46rom what I can see, this location is the only place I've come = accross in the FreeBSD kernel, where a SYSINIT() is used inside a = function, and I thought I would just move that outside the function = instead. >=20 > This change also allows for: >=20 > https://reviews.freebsd.org/D40193 Which looks like a mess to me. Jess > --HPS