All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Alexander Potapenko <glider@google.com>
Cc: catalin.marinas@arm.com, will@kernel.org, pcc@google.com,
	andreyknvl@gmail.com, linux@rasmusvillemoes.dk,
	yury.norov@gmail.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, eugenis@google.com
Subject: Re: [v2 3/5] arm64: mte: implement CONFIG_ARM64_MTE_COMP
Date: Fri, 14 Jul 2023 13:47:21 +0300	[thread overview]
Message-ID: <ZLEnublo8C5yX3si@smile.fi.intel.com> (raw)
In-Reply-To: <CAG_fn=W4Uv2YaO=Udwo80_f74y8o0+WWVVqTNK3iW5VDs5B8+w@mail.gmail.com>

On Fri, Jul 14, 2023 at 11:25:41AM +0200, Alexander Potapenko wrote:

...

> > Not sure why fls() / BIT() can't be used directly instead of these functions,
> > but okay, they are not too ugly.
> 
> They can't be used directly because 128 maps to 0, but I can sure
> simplify them a bit.

Right, that's why I'm okay with the current implementation. But
if you want to rewrite, up to you.

...

> > > +                     if (pos % 2 == 0)
> >
> > Would be better to keep this aligned with above?
> >
> >                         if (pos % 2)
> >                                 ...
> >                         else
> >                                 ...
> 
> It would, but i % 2 above didn't survive the rewrite, so I assume it
> is fine to keep pos % 2 == 0 as is.

Not big deal, but less characters improve the brain process, so

	if (pos % 2)

kinda quicker to read and understand in my opinion.

...

> > > +EXPORT_SYMBOL(ea0_storage_size);
> >
> > Btw, can we go to the namespaced export from day 1?
> 
> Am I getting it right that I just need to change EXPORT_SYMBOL to
> EXPORT_SYMBOL_NS and import the namespace in
> arch/arm64/mm/test_mtecomp.c?
> I.e. MODULE_IMPORT_NS is not needed in mteswap_comp.c, because it is
> linked into the kernel?

I think you always need to include MODULE_IMPORT_NS for the sake of
robustness of the code.

...

> > > +             if (sizes[i] > largest) {
> > > +                     largest = sizes[i];
> > > +                     largest_idx = i;
> > > +             }
> >
> > (alas max_array() can't be used here)
> There's no max_array() in the kernel, am I missing something?

There will be (via ASoC tree and maybe IIO tree later on) in v6.6-rc1, but
as I think it can't be used anyway because you need the index of the value
as well.

...

> > > +void ea0_release_handle(u64 handle)
> > > +{
> > > +     void *storage = ea0_storage(handle);
> > > +     int size = ea0_storage_size(handle);
> > > +     struct kmem_cache *c;
> >
> > > +     if (!handle || !storage)
> > > +             return;
> >
> > You use handle before this check. Haven't you run static analysers?
> 
> Sparse doesn't report anything in these files, are there any
> alternatives adopted in the kernel?
> 
> Note that handle is not dereferenced above, so there's no error per se.

Even if it's a simple pointer arithmetics, the storage might (theoretically?)
have a dangling pointer, no?

> Yet (as pointed out below) these checks are redundant, so I'll remove
> some of them.

...

> > > +
> >
> > Unneeded blank line.
> 
> I think there's no agreement on this in the kernel code, but my
> version is more popular:
> 
> $ git grep -B2 '^module_init(' | grep '\-}' -A2 | grep module_init | wc
>    2688    2707  164023
> $ git grep -B2 '^module_init(' | grep '\-}' -A1 | grep module_init | wc
>     505     523   30989

Even though, there is no need for this blank line. And note, for better
argument, compare this for the new code added let's say for the past 2
years. I believe numbers will tend to my variant.

I.o.w. you need to count on trends and not only on frequencies.

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Alexander Potapenko <glider@google.com>
Cc: catalin.marinas@arm.com, will@kernel.org, pcc@google.com,
	andreyknvl@gmail.com, linux@rasmusvillemoes.dk,
	yury.norov@gmail.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, eugenis@google.com
Subject: Re: [v2 3/5] arm64: mte: implement CONFIG_ARM64_MTE_COMP
Date: Fri, 14 Jul 2023 13:47:21 +0300	[thread overview]
Message-ID: <ZLEnublo8C5yX3si@smile.fi.intel.com> (raw)
In-Reply-To: <CAG_fn=W4Uv2YaO=Udwo80_f74y8o0+WWVVqTNK3iW5VDs5B8+w@mail.gmail.com>

On Fri, Jul 14, 2023 at 11:25:41AM +0200, Alexander Potapenko wrote:

...

> > Not sure why fls() / BIT() can't be used directly instead of these functions,
> > but okay, they are not too ugly.
> 
> They can't be used directly because 128 maps to 0, but I can sure
> simplify them a bit.

Right, that's why I'm okay with the current implementation. But
if you want to rewrite, up to you.

...

> > > +                     if (pos % 2 == 0)
> >
> > Would be better to keep this aligned with above?
> >
> >                         if (pos % 2)
> >                                 ...
> >                         else
> >                                 ...
> 
> It would, but i % 2 above didn't survive the rewrite, so I assume it
> is fine to keep pos % 2 == 0 as is.

Not big deal, but less characters improve the brain process, so

	if (pos % 2)

kinda quicker to read and understand in my opinion.

...

> > > +EXPORT_SYMBOL(ea0_storage_size);
> >
> > Btw, can we go to the namespaced export from day 1?
> 
> Am I getting it right that I just need to change EXPORT_SYMBOL to
> EXPORT_SYMBOL_NS and import the namespace in
> arch/arm64/mm/test_mtecomp.c?
> I.e. MODULE_IMPORT_NS is not needed in mteswap_comp.c, because it is
> linked into the kernel?

I think you always need to include MODULE_IMPORT_NS for the sake of
robustness of the code.

...

> > > +             if (sizes[i] > largest) {
> > > +                     largest = sizes[i];
> > > +                     largest_idx = i;
> > > +             }
> >
> > (alas max_array() can't be used here)
> There's no max_array() in the kernel, am I missing something?

There will be (via ASoC tree and maybe IIO tree later on) in v6.6-rc1, but
as I think it can't be used anyway because you need the index of the value
as well.

...

> > > +void ea0_release_handle(u64 handle)
> > > +{
> > > +     void *storage = ea0_storage(handle);
> > > +     int size = ea0_storage_size(handle);
> > > +     struct kmem_cache *c;
> >
> > > +     if (!handle || !storage)
> > > +             return;
> >
> > You use handle before this check. Haven't you run static analysers?
> 
> Sparse doesn't report anything in these files, are there any
> alternatives adopted in the kernel?
> 
> Note that handle is not dereferenced above, so there's no error per se.

Even if it's a simple pointer arithmetics, the storage might (theoretically?)
have a dangling pointer, no?

> Yet (as pointed out below) these checks are redundant, so I'll remove
> some of them.

...

> > > +
> >
> > Unneeded blank line.
> 
> I think there's no agreement on this in the kernel code, but my
> version is more popular:
> 
> $ git grep -B2 '^module_init(' | grep '\-}' -A2 | grep module_init | wc
>    2688    2707  164023
> $ git grep -B2 '^module_init(' | grep '\-}' -A1 | grep module_init | wc
>     505     523   30989

Even though, there is no need for this blank line. And note, for better
argument, compare this for the new code added let's say for the past 2
years. I believe numbers will tend to my variant.

I.o.w. you need to count on trends and not only on frequencies.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-07-14 10:47 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-13 12:57 [v2 0/5] Implement MTE tag compression for swapped pages Alexander Potapenko
2023-07-13 12:57 ` Alexander Potapenko
2023-07-13 12:57 ` [v2 1/5] lib/bitmap: add bitmap_{set,get}_value_unaligned() Alexander Potapenko
2023-07-13 12:57   ` Alexander Potapenko
2023-07-13 17:28   ` Andy Shevchenko
2023-07-13 17:28     ` Andy Shevchenko
2023-07-13 18:05     ` Alexander Potapenko
2023-07-13 18:05       ` Alexander Potapenko
2023-07-14  8:04       ` Andy Shevchenko
2023-07-14  8:04         ` Andy Shevchenko
2023-07-14 11:19         ` William Breathitt Gray
2023-07-14 11:19           ` William Breathitt Gray
2023-07-14 11:28           ` Andy Shevchenko
2023-07-14 11:28             ` Andy Shevchenko
2023-07-14 12:07             ` Alexander Potapenko
2023-07-14 12:07               ` Alexander Potapenko
2023-07-14 12:30               ` Andy Shevchenko
2023-07-14 12:30                 ` Andy Shevchenko
2023-07-13 12:57 ` [v2 2/5] lib/test_bitmap: add tests for bitmap_{set,get}_value_unaligned Alexander Potapenko
2023-07-13 12:57   ` Alexander Potapenko
2023-07-13 12:57 ` [v2 3/5] arm64: mte: implement CONFIG_ARM64_MTE_COMP Alexander Potapenko
2023-07-13 12:57   ` Alexander Potapenko
2023-07-13 16:37   ` Alexander Potapenko
2023-07-13 16:37     ` Alexander Potapenko
2023-07-13 17:23   ` Andy Shevchenko
2023-07-13 17:23     ` Andy Shevchenko
2023-07-13 19:27     ` Yury Norov
2023-07-13 19:27       ` Yury Norov
2023-07-14  8:01       ` Andy Shevchenko
2023-07-14  8:01         ` Andy Shevchenko
2023-07-14  9:25     ` Alexander Potapenko
2023-07-14  9:25       ` Alexander Potapenko
2023-07-14 10:47       ` Andy Shevchenko [this message]
2023-07-14 10:47         ` Andy Shevchenko
2023-07-14 11:17         ` Alexander Potapenko
2023-07-14 11:17           ` Alexander Potapenko
2023-07-13 12:57 ` [v2 4/5] arm64: mte: add a test for MTE tags compression Alexander Potapenko
2023-07-13 12:57   ` Alexander Potapenko
2023-07-13 12:57 ` [v2 5/5] arm64: mte: add compression support to mteswap.c Alexander Potapenko
2023-07-13 12:57   ` Alexander Potapenko

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=ZLEnublo8C5yX3si@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=andreyknvl@gmail.com \
    --cc=catalin.marinas@arm.com \
    --cc=eugenis@google.com \
    --cc=glider@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=pcc@google.com \
    --cc=will@kernel.org \
    --cc=yury.norov@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.