Re: [PATCH] memset 0 in obscure is optimized away by compiler

2022-10-05 Thread Rolf Eike Beer
Am Samstag, 1. Oktober 2022, 21:48:39 CEST schrieb Bernhard Reutner-Fischer:
> On Wed, 16 Apr 2014 20:25:39 -0400
> 
> > That's exactly the situation here. The lifetime of the object being
> > cleared by memset ends sufficiently close to the memset that the
> > compiler is able to achieve the same observable effects that would be
> > seen in the abstract machine without actually performing any memory
> > fill.
> 
> There are several possibilities out there in the wild that currently
> work around the (unimplemented, everywhere) microsoft _s "extension".
> 
> 3) ...

Use explicit_bzero() when available, or create such a function for 
configurations where it is not.

Eike
-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source


signature.asc
Description: This is a digitally signed message part.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] Huge performance boost for recursion (cp, du, find, ls, rm, , mv)

2024-04-10 Thread Rolf Eike Beer
On Mittwoch, 10. April 2024 21:36:06 CEST Jody Bruchon wrote:
> This patch uses pre-calculated name lengths to massively speed up various
> recursive operations. Three new *_fast variant functions are added along
> with get_d_namlen copied from libjodycode. Passing lengths allows use of
> memcpy() instead of strcpy()/strcat() and replacement of a particularly
> hot xasprintf(). Cachegrind shows CPU instructions on Linux x86_64 drop
> by 24% to 67% with similar reductions in data reads and writes.
> 
> Anything in BusyBox that uses a while(readdir()) loop or that calls
> concat_*path_file() or last_char_is() might benefit from adopting this
> optimization framework.

Completely untested, but how about this:

char* FAST_FUNC concat_path_file_fast(const char *path, const struct dirent 
*dirp)
{
const char *filename = dirp->d_name;
char *buf;
int end_offset;
int pathlen, namelen;

if (!path) {
path = "";
pathlen = 0;
} else {
pathlen = strlen(path);
if (last_char_is_fast(path, '/', pathlen) == NULL) 
pathlen--;
}
namelen = get_d_namlen(dirp);
while (*filename == '/') {
filename++;
namelen--;
}
end_offset = pathlen + 1 + namelen;
buf = (char *)malloc(end_offset + 1);
if (!buf) return NULL;
memcpy(buf, path, pathlen);
*(buf + pathlen) = '/';
memcpy(buf + pathlen + 1, filename, namelen);
*(buf + end_offset) = '\0';
return buf;
}

This avoids scanning an empty path for the trailing slash, and avoids the 
check for a trailing slash later entirely, saving one instruction and 2 
variables.

You also have quite some places where you have the old code still around and 
just commented out, I would have just removed them.

Generally I wonder if the length variables shouldn't be size_t or the like, 
which would not affect this function but all of them.

Eike
-- 
Besuchen Sie uns auf der Embedded World 2024
9. bis 11. April 2024 | Messe Nürnberg
Sie finden uns in Halle 4, Stand 336

--
Rolf Eike Beer

emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail i...@emlix.com
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com

emlix - your embedded Linux partner

signature.asc
Description: This is a digitally signed message part.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] Huge performance boost for recursion (cp, du, find, ls, rm, , mv)

2024-04-15 Thread Rolf Eike Beer
On Montag, 15. April 2024 17:14:11 MESZ Jody Bruchon wrote:
> With these changes, 'busybox find .' and 'busybox find libbb' fail
> entirely, with 'libbb' becoming 'libb' instead. Running 'busybox find
> libbb/' works but the result has double-slashes: 'libbb//whatever.c'.
> The last char of the parameter passed to 'find' is being erased if there
> is no slash.

This line is wrong:

> if (last_char_is_fast(path, '/', pathlen) == NULL) pathlen--;

If you replace "==" with "!=" it works.

Regard,

Eike
-- 
Rolf Eike Beer

emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail i...@emlix.com
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com

emlix - your embedded Linux partner

signature.asc
Description: This is a digitally signed message part.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] examples/udhcp/simple.script: fix resolv.conf update if it is a dangling symlink

2019-03-28 Thread Rolf Eike Beer
If /etc/resolv.conf is a symlink to a tmpfs and the actual file does not
already exist, "readlink -f" will not detect it as symlink. Explicitely check
for that condition before and touch the file, making the other code work as
intended.

Signed-off-by: Rolf Eike Beer 
---
 examples/udhcp/simple.script | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/examples/udhcp/simple.script b/examples/udhcp/simple.script
index 44aa46ece..57fb3e431 100755
--- a/examples/udhcp/simple.script
+++ b/examples/udhcp/simple.script
@@ -55,6 +55,9 @@ case "$1" in
echo "Recreating $RESOLV_CONF"
# If the file is a symlink somewhere (like /etc/resolv.conf
# pointing to /run/resolv.conf), make sure things work.
+   if [ -L $RESOLV_CONF -a ! -f $RESOLV_CONF ]; then
+   touch $RESOLV_CONF
+   fi
realconf=$(readlink -f "$RESOLV_CONF" 2>/dev/null || echo 
"$RESOLV_CONF")
tmpfile="$realconf-$$"
> "$tmpfile"
-- 
2.21.0
-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source



___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


passwd crashes since ce51140664d82300d25b096b4a41f01fdfd766b3

2019-06-24 Thread Rolf Eike Beer
Hi,

we have a project using uclibc-ng (tested both version 1.0.29 and 1.0.31) and 
busybox. Since commit ce51140664d82300d25b096b4a41f01fdfd766b3 passwd crashes 
(segfault) when doing this:

echo -e "${OTP}\n${OTP}" | (/usr/bin/passwd -- user)

Reverting the commit fixes the crash and restores functionality, but of course 
the original bug would be there again.

Greetings,

Eike
-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source

signature.asc
Description: This is a digitally signed message part.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: passwd crashes since ce51140664d82300d25b096b4a41f01fdfd766b3

2019-06-25 Thread Rolf Eike Beer
Am Montag, 24. Juni 2019, 11:03:59 CEST schrieb Rolf Eike Beer:
> Hi,
> 
> we have a project using uclibc-ng (tested both version 1.0.29 and 1.0.31)
> and busybox. Since commit ce51140664d82300d25b096b4a41f01fdfd766b3 passwd
> crashes (segfault) when doing this:
> 
>   echo -e "${OTP}\n${OTP}" | (/usr/bin/passwd -- user)
> 
> Reverting the commit fixes the crash and restores functionality, but of
> course the original bug would be there again.

It looks like I have severely messed up branches and commit ids when writing 
this mail and testing this. It could be that all this is incorrect. Please 
don't invest any time into this issue until further notice, I'll rebuild and 
retest.

Eike
-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source

signature.asc
Description: This is a digitally signed message part.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: passwd crashes since ce51140664d82300d25b096b4a41f01fdfd766b3

2019-06-27 Thread Rolf Eike Beer
Am Dienstag, 25. Juni 2019, 12:34:33 CEST schrieb Rolf Eike Beer:
> Am Montag, 24. Juni 2019, 11:03:59 CEST schrieb Rolf Eike Beer:
> > Hi,
> > 
> > we have a project using uclibc-ng (tested both version 1.0.29 and 1.0.31)
> > and busybox. Since commit ce51140664d82300d25b096b4a41f01fdfd766b3 passwd
> > 
> > crashes (segfault) when doing this:
> > echo -e "${OTP}\n${OTP}" | (/usr/bin/passwd -- user)
> > 
> > Reverting the commit fixes the crash and restores functionality, but of
> > course the original bug would be there again.
> 
> It looks like I have severely messed up branches and commit ids when writing
> this mail and testing this. It could be that all this is incorrect. Please
> don't invest any time into this issue until further notice, I'll rebuild
> and retest.

Ok, sorry for the noise everyone. Looks like I have indeed screwed things up 
when trying to document what happened. The given commit actually _fixes_ the 
problems I see when cherry-picked on top of 1.30.1, so all is fine.

Eike
-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source

signature.asc
Description: This is a digitally signed message part.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] examples/udhcp/simple.script: print the filename actually changed

2019-08-13 Thread Rolf Eike Beer
Signed-off-by: Rolf Eike Beer 
---
 examples/udhcp/simple.script | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/udhcp/simple.script b/examples/udhcp/simple.script
index 53974e6d6..61cc3fe1f 100755
--- a/examples/udhcp/simple.script
+++ b/examples/udhcp/simple.script
@@ -52,7 +52,6 @@ case "$1" in
done
fi
 
-   echo "Recreating $RESOLV_CONF"
# If the file is a symlink somewhere (like /etc/resolv.conf
# pointing to /run/resolv.conf), make sure things work.
if test -L "$RESOLV_CONF"; then
@@ -60,6 +59,7 @@ case "$1" in
test -e "$RESOLV_CONF" || touch "$RESOLV_CONF"
fi
realconf=$(readlink -f "$RESOLV_CONF" 2>/dev/null || echo 
"$RESOLV_CONF")
+   echo "Recreating $realconf"
tmpfile="$realconf-$$"
    > "$tmpfile"
[ -n "$domain" ] && echo "search $domain" >> "$tmpfile"
-- 
2.22.0


-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source


___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Some issues in examples/udhcp/simple.script

2019-08-14 Thread Rolf Eike Beer
Hi all,

I have discovered some problems with examples/udhcp/simple.script. I know, 
it's an example, and a simplified one. Most people will still just use it 
because it works, so I would like to point out at least some things.

First, it does not really use ip. At least not if "command" does not exist. 
Fair enough, I know I have ip, so I just deleted the checks and the ifconfig 
lines.

This makes it do nothing. As I found out the culprit is this:

if command -v ip >/dev/null; then
ip addr flush dev $interface
else
ifconfig $interface 0.0.0.0
fi

The difference between both cases is: ifconfig brings up the interface, ip 
with this command does not. So if you are using ip this will just send DHCP 
request to a network interface that has link down, which will not get you 
anywhere.

Greetings,

Eike
-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source

signature.asc
Description: This is a digitally signed message part.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Some issues in examples/udhcp/simple.script

2019-09-05 Thread Rolf Eike Beer
Am Donnerstag, 5. September 2019, 14:57:15 CEST schrieb Denys Vlasenko:
> On Wed, Aug 14, 2019 at 9:50 AM Rolf Eike Beer  wrote:
> > Hi all,
> > 
> > I have discovered some problems with examples/udhcp/simple.script. I know,
> > it's an example, and a simplified one. Most people will still just use it
> > because it works, so I would like to point out at least some things.
> > 
> > First, it does not really use ip. At least not if "command" does not
> > exist.
> 
> "command" is a mandatory shell builtin.
> 
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
> 
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
> section "Command Search and Execution" specifically mentions it.
> 
> The reason for this mention is that its function
> can not reasonably be implemented as a separate external tool,
> since external tools don't know what functions are defined
> in current shell's invocation, thus "command FUNCNAME"
> won't work.
> 
> Since it's an internal builtin, using it should be a fastest way to test
> whether "ip" can be executed, without assuming a path
> ("test -x /usr/bin/ip") or forking a possibly external tool
> ("which ip").
> 
> Which shell do you use so that you don't have "command"?

Busybox ash:

# command ip
-sh: command: not found
# ip a
1: lo:  mtu 65536 qdisc noqueue qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
…

> > The difference between both cases is: ifconfig brings up the interface, ip
> > with this command does not. So if you are using ip this will just send
> > DHCP
> > request to a network interface that has link down, which will not get you
> > anywhere.
> 
> Yes, this is different. How about:
> 
> echo "Clearing IP addresses on $interface, upping it"
> if command -v ip >/dev/null; then
>     ip addr flush dev $interface
> ip link set dev $interface up
> else
> ifconfig $interface 0.0.0.0
> fi

Which is basically what I'm using now, just different order of commands.

Thanks,

Eike
-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source

signature.asc
Description: This is a digitally signed message part.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] examples/udhcp/simple.script: print the filename actually changed

2019-09-10 Thread Rolf Eike Beer
Am Dienstag, 13. August 2019, 17:41:56 CEST schrieb Rolf Eike Beer:

> Signed-off-by: Rolf Eike Beer 
> ---
>  examples/udhcp/simple.script | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/examples/udhcp/simple.script b/examples/udhcp/simple.script
> index 53974e6d6..61cc3fe1f 100755
> --- a/examples/udhcp/simple.script
> +++ b/examples/udhcp/simple.script
> @@ -52,7 +52,6 @@ case "$1" in
>   done
>   fi
> 
> - echo "Recreating $RESOLV_CONF"
>   # If the file is a symlink somewhere (like /etc/
resolv.conf
>   # pointing to /run/resolv.conf), make sure things work.
>   if test -L "$RESOLV_CONF"; then
> @@ -60,6 +59,7 @@ case "$1" in
>   test -e "$RESOLV_CONF" || touch 
"$RESOLV_CONF"
>   fi
>   realconf=$(readlink -f "$RESOLV_CONF" 2>/dev/null || 
echo "$RESOLV_CONF")
> + echo "Recreating $realconf"
>       tmpfile="$realconf-$$"
> 
>   > "$tmpfile"
> 
>   [ -n "$domain" ] && echo "search $domain" >> "$tmpfile"

Ping?
-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source

signature.asc
Description: This is a digitally signed message part.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] Remove stime() function calls

2020-02-03 Thread Rolf Eike Beer
Am Mittwoch, 20. November 2019, 19:18:44 CET schrieb Denys Vlasenko:
> Applied with a bit of change, thanks!

Ok, glibc 2.31 is out and now the fun starts. This patch can't simply be 
cherry-picked on top of 1.31.1 because it collides with 
6937487be73cd4563b876413277a295a5fe2f32c. Not much work to fix that I believe, 
but still inefficient if multiple people now start testing their patch skills. 
Can we get a fixed version instead, please?

Greetings,

Eike
-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source

Besuchen Sie uns auf der Embedded World 2020 in Nürnberg!
-> Halle 4, Stand 368


signature.asc
Description: This is a digitally signed message part.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox