History log of /openbmc/obmc-console/ringbuffer.c (Results 1 – 12 of 12)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 2f1abc37 04-Jun-2024 John Wang <wangzhiqiang02@ieisystem.com>

Fix realloc() with size 0

Valgrind reported “realloc() with size 0"

'''
==508== realloc() with size 0
==508== at 0x484DB80: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==50

Fix realloc() with size 0

Valgrind reported “realloc() with size 0"

'''
==508== realloc() with size 0
==508== at 0x484DB80: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==508== by 0x1093E3: ringbuffer_consumer_unregister (ringbuffer.c:103)
==508== by 0x10942B: ringbuffer_fini (ringbuffer.c:48)
==508== by 0x109989: test_simple_poll (test-ringbuffer-simple-poll.c:31)
==508== by 0x109A3A: main (test-ringbuffer-simple-poll.c:37)
'''

And gnu libc manual[1] said:
Portable programs should not attempt to reallocate blocks to be size
zero. On other implementations if ptr is non-null, realloc (ptr, 0)
might free the block and return a non-null pointer to a size-zero
object, or it might fail and return NULL without freeing the block.
The ISO C17 standard allows these variations.

So use free instead of realloc with size 0

[1] https://www.gnu.org/software/libc/manual/html_node/Changing-Block-Size.html
Change-Id: Ie716dd6ea84696a2091c680d71a0624423d1a185
Signed-off-by: John Wang <wangzhiqiang02@ieisystem.com>

show more ...


Revision tags: v1.1.0
# 1b868441 18-Apr-2023 Andrew Jeffery <andrew@aj.id.au>

obmc-console: Fix ringbuffer-test-utils analysis

ninja's clang-tidy target barfs due to the strategy of including C files
into each other for test purposes. Help it out by moving the ringbuffer
stru

obmc-console: Fix ringbuffer-test-utils analysis

ninja's clang-tidy target barfs due to the strategy of including C files
into each other for test purposes. Help it out by moving the ringbuffer
struct definitions into console-server.h so it can find them when
analysing test/ringbuffer-test-utils.c.

obmc-console isn't a library, so it's not like we're trying to avoid
expanding API/ABI surface.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ifd4501d3ca7f3bb02c557a1c31364aadd2b26abe

show more ...


# b70f8713 18-Apr-2023 Andrew Jeffery <andrew@aj.id.au>

obmc-console: Fix readability-isolate-declaration

For example:

```
/usr/bin/clang-tidy -checks=-*, readability-isolate-declaration -export-fixes /tmp/tmpoo7fbs72/tmpo8xiwfxs.yaml -p=build /mnt/host

obmc-console: Fix readability-isolate-declaration

For example:

```
/usr/bin/clang-tidy -checks=-*, readability-isolate-declaration -export-fixes /tmp/tmpoo7fbs72/tmpo8xiwfxs.yaml -p=build /mnt/host/andrew/home/andrew/src/openbmc/obmc-console/test/test-client-escape.c
/mnt/host/andrew/home/andrew/src/openbmc/obmc-console/build/../config.c:61:2: error: multiple declarations in a single statement reduces readability [readability-isolate-declaration,-warnings-as-errors]
char *name, *value;
^~~~~~~~~~~~~~~~~~~
/mnt/host/andrew/home/andrew/src/openbmc/obmc-console/build/../config.c:62:2: error: multiple declarations in a single statement reduces readability [readability-isolate-declaration,-warnings-as-errors]
char *p, *line;
^~~~~~~~~~~~~~~
/mnt/host/andrew/home/andrew/src/openbmc/obmc-console/build/../config.c:110:2: error: multiple declarations in a single statement reduces readability [readability-isolate-declaration,-warnings-as-errors]
size_t size, len;
^~~~~~~~~~~~~~~~~
/mnt/host/andrew/home/andrew/src/openbmc/obmc-console/build/../config.c:170:2: error: multiple declarations in a single statement reduces readability [readability-isolate-declaration,-warnings-as-errors]
struct config_item *item, *next;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/host/andrew/home/andrew/src/openbmc/obmc-console/build/../console-client.c:263:2: error: multiple declarations in a single statement reduces readability [readability-isolate-declaration,-warnings-as-errors]
struct console_client _client, *client;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 warnings generated.
```

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ia7829b1672ea2dfb3fa020c7c48bd8266e6a1769

show more ...


# 0b7b0477 18-Apr-2023 Andrew Jeffery <andrew@aj.id.au>

obmc-console: Fix readability-else-after-return

```
/usr/bin/clang-tidy -checks=-*, readability-else-after-return -export-fixes /tmp/tmpzmyw6on0/tmpdk8wt96i.yaml -p=build /mnt/host/andrew/home/andre

obmc-console: Fix readability-else-after-return

```
/usr/bin/clang-tidy -checks=-*, readability-else-after-return -export-fixes /tmp/tmpzmyw6on0/tmpdk8wt96i.yaml -p=build /mnt/host/andrew/home/andrew/src/openbmc/obmc-console/test/test-ringbuffer-boundary-poll.c
/mnt/host/andrew/home/andrew/src/openbmc/obmc-console/build/../ringbuffer.c:131:4: error: do not use 'else' after 'return' [readability-else-after-return,-warnings-as-errors]
} else {
^~~~~~
```

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ic80538a64f061f9ed3d3d71293dcf4f3d99cb6e4

show more ...


# 2834c5b1 18-Apr-2023 Andrew Jeffery <andrew@aj.id.au>

obmc-console: Fix readability-braces-around-statements

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I88d2bdcb15106298d83a1cf7176e069092820f1d


# 91b52175 18-Apr-2023 Andrew Jeffery <andrew@aj.id.au>

obmc-console: Address bugprone-sizeof-expression

Disable the lint where we know the implementation is valid, but do not
disable it globally.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-I

obmc-console: Address bugprone-sizeof-expression

Disable the lint where we know the implementation is valid, but do not
disable it globally.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ie1640d82138fe91a401188cf966250103a25dde6

show more ...


# 19c74d58 18-Apr-2023 Andrew Jeffery <andrew@aj.id.au>

obmc-console: Extract definition of _GNU_SOURCE

Avoid triggering bugprone-reserved-identifier

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I8b4d40c92c1e9633bdb078c3f8d6d97ffb248cc2


# 5c359cc6 18-Apr-2023 Andrew Jeffery <andrew@aj.id.au>

obmc-console: Fix bugprone-narrowing-conversions

For example:

```
/mnt/host/andrew/home/andrew/src/openbmc/obmc-console/build/../console-server.c:769:9: error: narrowing conversion from 'ssize_t' (

obmc-console: Fix bugprone-narrowing-conversions

For example:

```
/mnt/host/andrew/home/andrew/src/openbmc/obmc-console/build/../console-server.c:769:9: error: narrowing conversion from 'ssize_t' (aka 'long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
rc = read(console->tty_fd, buf, sizeof(buf));
^
```

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I67c158b411f1533ca3b5a62803116e95907e8c5b

show more ...


# a72711af 18-Apr-2023 Andrew Jeffery <andrew@aj.id.au>

obmc-console: Add clang-format configuration

And apply the formatting.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I75251051affa5129c8698185baf8d151302b19d6


# 15ceb3e3 17-Apr-2023 Andrew Jeffery <andrew@aj.id.au>

ringbuffer: Implement min() as an inline function

```
cc -Iobmc-console-server.p -I. -I.. -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -Werror -std=gnu17

ringbuffer: Implement min() as an inline function

```
cc -Iobmc-console-server.p -I. -I.. -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -Werror -std=gnu17 -O2 -g '-DLOCALSTATEDIR="/var/local"' '-DSYSCONFDIR="etc"' -MD -MQ obmc-console-server.p/ringbuffer.c.o -MF obmc-console-server.p/ringbuffer.c.o.d -o obmc-console-server.p/ringbuffer.c.o -c ../ringbuffer.c
../ringbuffer.c: In function ‘ringbuffer_queue’:
../ringbuffer.c:26:18: error: ISO C forbids braced-groups within expressions [-Werror=pedantic]
26 | #define min(a,b) ({ \
| ^
../ringbuffer.c:173:16: note: in expansion of macro ‘min’
173 | wlen = min(len, rb->size - rb->tail);
| ^~~
cc1: all warnings being treated as errors
```

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I17f117fb0b6dc7941b119e435a37f3c862296754

show more ...


# 1cecc5de 28-Feb-2019 Johnathan Mantey <johnathanx.mantey@intel.com>

Eliminate excessive CPU consumption when redirecting UART over SSH

Redirecting the external UART via SSH caused the console-server,
console-client, and dropbear to consume ~30% of the available CPU

Eliminate excessive CPU consumption when redirecting UART over SSH

Redirecting the external UART via SSH caused the console-server,
console-client, and dropbear to consume ~30% of the available CPU each
when a large amount of data was being written to the UART output.

Buffering all of the small 16550 FIFO bytes into a larger packet and
then sending that to the SSH SW allows more efficient transmission
over the ethernet connection.

Tested this by "ssh root@<bmc.ip.addr> -p 2200" on a system running a
CentOS distribution. Using a BASH console run a large binary file
through "od -t x1 <fname>" to create a large amount of traffic. At
the BMC console run "top" to review the CPU usage. My experience is
after this change is applied:
console-server: ~25% CPU
dropbear: ~3% CPU
console-client: ~1% CPU

Change-Id: Ibabfd285e97a487e7ff040e1cb3159fbff360328
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>

show more ...


# c9775ce7 07-Feb-2017 Jeremy Kerr <jk@ozlabs.org>

server: Use ringbuffer for socket backlog

Currently, the socket handler uses a linear buffer for the backlog data;
this means we need to shift up to 128kB of data after each socket
write().

This ch

server: Use ringbuffer for socket backlog

Currently, the socket handler uses a linear buffer for the backlog data;
this means we need to shift up to 128kB of data after each socket
write().

This change introduces a single-producer-multiple-consumer ringbuffer,
to avoid the need for memmove()ing data around; we can simply update
pointers instead of shifting data.

We add this as a new file (ringbuffer.c), to make it a little more
modular. To mitigate the risk of subtle pointer arithmetic issues, we
add a set of tests too.

Change-Id: Ib7c5151d3cf1f588436f5461000b6fed22d0681c
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>

show more ...