From: Junio C Hamano <gitster@pobox.com>
To: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>
Cc: git@vger.kernel.org, brad@comstyle.com, collin.funk1@gmail.com,
pclouds@gmail.com, ps@pks.im
Subject: Re: [PATCH v3] builtin/gc: correct total_ram calculation with HAVE_BSD_SYSCTL
Date: Wed, 02 Jul 2025 15:59:59 -0700 [thread overview]
Message-ID: <xmqq1pqyci6o.fsf@gitster.g> (raw)
In-Reply-To: <ep4q5xwbys4qwpkmmo5jujzjorrb24v5na4yuwpjr5owojwk2q@omb7xpp4oov5> ("Carlo Marcelo Arenas Belón"'s message of "Wed, 2 Jul 2025 15:42:03 -0700")
Carlo Marcelo Arenas Belón <carenas@gmail.com> writes:
>> > + physical_memory <<= bits;
>> > + physical_memory >>= bits;
>>
>> I do not quite understand this version. Does the correctness of
>> this depend on the machine having a certain byte-order?
> ...
> the shifting was meant to be a cooler way to get those bits cleared,
> because I thought that relying in the initialization wasn't as cool
> from the previous comments.
I more often have seen a pattern like
physical_memory &= ((1U << bits) - 1);
for clearing the upper bits, but that's fine.
> a fixed version of this, would allow at least a better return, and
> because most of the extra work is only needed in Big Endian (which
> could only affect Power) then it is almost a free upgrade.
OK. As this is not a performance-critical operation anyway, I am
perfectly OK with the dumb "we ask for 8 and be happy if the answer
is 8 bytes long. Otherwise if the answer is 4, we prepare a u32 and
ask again with 4; other "possible" answer width like 2 or 6 are
probably not worth worrying about" ;-).
Thanks.
next prev parent reply other threads:[~2025-07-02 23:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 14:42 [PATCH] builtin/gc: improve total_ram calculation for HAVE_BSD_SYSCTL Carlo Marcelo Arenas Belón
2025-07-02 15:23 ` Patrick Steinhardt
2025-07-02 17:04 ` Carlo Marcelo Arenas Belón
2025-07-02 15:46 ` [PATCH v2] builtin/gc: protect against sysctl() failure in total_ram Carlo Marcelo Arenas Belón
2025-07-02 18:42 ` Junio C Hamano
2025-07-02 20:22 ` Carlo Marcelo Arenas Belón
2025-07-02 20:59 ` Junio C Hamano
2025-07-02 20:21 ` [PATCH v3] builtin/gc: correct total_ram calculation with HAVE_BSD_SYSCTL Carlo Marcelo Arenas Belón
2025-07-02 21:14 ` Junio C Hamano
2025-07-02 22:42 ` Carlo Marcelo Arenas Belón
2025-07-02 22:59 ` Junio C Hamano [this message]
2025-07-03 8:01 ` [PATCH v4] " Carlo Marcelo Arenas Belón
2025-07-07 13:39 ` Junio C Hamano
2025-07-07 16:45 ` [PATCH v5] " Carlo Marcelo Arenas Belón
2025-07-07 17:09 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq1pqyci6o.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=brad@comstyle.com \
--cc=carenas@gmail.com \
--cc=collin.funk1@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).