* [PATCH] printk: ringbuffer: Convert function argument to local variable
@ 2020-11-10 12:50 Nikolay Borisov
2020-11-10 13:14 ` John Ogness
0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Borisov @ 2020-11-10 12:50 UTC (permalink / raw)
To: pmladek, sergey.senozhatsky
Cc: john.ogness, linux-kernel, rostedt, Nikolay Borisov
data_alloc's 2nd argument is always rb::text_data_ring and that functino
always takes a struct printk_ringbuffer. Instead of passing the data
ring buffer as an argument simply make it a local variable.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
kernel/printk/printk_ringbuffer.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/kernel/printk/printk_ringbuffer.c b/kernel/printk/printk_ringbuffer.c
index 6b1525685277..7f2713e1bbcc 100644
--- a/kernel/printk/printk_ringbuffer.c
+++ b/kernel/printk/printk_ringbuffer.c
@@ -1021,10 +1021,10 @@ static unsigned long get_next_lpos(struct prb_data_ring *data_ring,
* if necessary. This function also associates the data block with
* a specified descriptor.
*/
-static char *data_alloc(struct printk_ringbuffer *rb,
- struct prb_data_ring *data_ring, unsigned int size,
+static char *data_alloc(struct printk_ringbuffer *rb, unsigned int size,
struct prb_data_blk_lpos *blk_lpos, unsigned long id)
{
+ struct prb_data_ring *data_ring = &rb->text_data_ring;
struct prb_data_block *blk;
unsigned long begin_lpos;
unsigned long next_lpos;
@@ -1397,7 +1397,7 @@ bool prb_reserve_in_last(struct prb_reserved_entry *e, struct printk_ringbuffer
if (r->text_buf_size > max_size)
goto fail;
- r->text_buf = data_alloc(rb, &rb->text_data_ring, r->text_buf_size,
+ r->text_buf = data_alloc(rb, r->text_buf_size,
&d->text_blk_lpos, id);
} else {
if (!get_data(&rb->text_data_ring, &d->text_blk_lpos, &data_size))
@@ -1549,8 +1549,7 @@ bool prb_reserve(struct prb_reserved_entry *e, struct printk_ringbuffer *rb,
if (info->seq > 0)
desc_make_final(desc_ring, DESC_ID(id - 1));
- r->text_buf = data_alloc(rb, &rb->text_data_ring, r->text_buf_size,
- &d->text_blk_lpos, id);
+ r->text_buf = data_alloc(rb, r->text_buf_size, &d->text_blk_lpos, id);
/* If text data allocation fails, a data-less record is committed. */
if (r->text_buf_size && !r->text_buf) {
prb_commit(e);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] printk: ringbuffer: Convert function argument to local variable
2020-11-10 12:50 [PATCH] printk: ringbuffer: Convert function argument to local variable Nikolay Borisov
@ 2020-11-10 13:14 ` John Ogness
2020-11-10 13:19 ` Nikolay Borisov
0 siblings, 1 reply; 3+ messages in thread
From: John Ogness @ 2020-11-10 13:14 UTC (permalink / raw)
To: Nikolay Borisov, pmladek, sergey.senozhatsky
Cc: linux-kernel, rostedt, Nikolay Borisov
On 2020-11-10, Nikolay Borisov <nborisov@suse.com> wrote:
> data_alloc's 2nd argument is always rb::text_data_ring and that functino
> always takes a struct printk_ringbuffer. Instead of passing the data
> ring buffer as an argument simply make it a local variable.
This is a relic of when we had a second data ring (for
dictionaries). The patch is a nice cleanup, but there are actually
several functions that could use this exact same cleanup:
- data_make_reusable()
- data_push_tail()
- data_alloc()
- data_realloc()
Perhaps we should fix them all in a single patch?
John Ogness
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] printk: ringbuffer: Convert function argument to local variable
2020-11-10 13:14 ` John Ogness
@ 2020-11-10 13:19 ` Nikolay Borisov
0 siblings, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2020-11-10 13:19 UTC (permalink / raw)
To: John Ogness, pmladek, sergey.senozhatsky; +Cc: linux-kernel, rostedt
On 10.11.20 г. 15:14 ч., John Ogness wrote:
> On 2020-11-10, Nikolay Borisov <nborisov@suse.com> wrote:
>> data_alloc's 2nd argument is always rb::text_data_ring and that functino
>> always takes a struct printk_ringbuffer. Instead of passing the data
>> ring buffer as an argument simply make it a local variable.
>
> This is a relic of when we had a second data ring (for
> dictionaries). The patch is a nice cleanup, but there are actually
> several functions that could use this exact same cleanup:
>
> - data_make_reusable()
> - data_push_tail()
> - data_alloc()
> - data_realloc()
>
> Perhaps we should fix them all in a single patch?
I observed that right after sending this patch, so I have authored the
necessary changes I can squash them and send them.
>
> John Ogness
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-10 13:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10 12:50 [PATCH] printk: ringbuffer: Convert function argument to local variable Nikolay Borisov
2020-11-10 13:14 ` John Ogness
2020-11-10 13:19 ` Nikolay Borisov
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).