Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Nuno Sá" <noname.nuno@gmail.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	linux-iio@vger.kernel.org,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Shen Jianping" <Jianping.Shen@de.bosch.com>
Subject: Re: [PATCH RFT] iio: Fix core buffer demux failure to account for unwanted channels at tail
Date: Wed, 6 Aug 2025 16:36:13 +0100	[thread overview]
Message-ID: <20250806163613.00003788@huawei.com> (raw)
In-Reply-To: <CAHp75VcWepvA73Pv=JHZn3BAnnO=NcaEvU85p2yQrVJW_pXFmw@mail.gmail.com>

On Tue, 5 Aug 2025 14:41:03 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Tue, Aug 5, 2025 at 10:16 AM Nuno Sá <noname.nuno@gmail.com> wrote:
> > On Mon, Aug 04, 2025 at 06:02:22PM +0200, Andy Shevchenko wrote:  
> > > On Mon, Aug 4, 2025 at 5:37 PM Nuno Sá <noname.nuno@gmail.com> wrote:  
> > > > On Sat, Aug 02, 2025 at 06:15:39PM +0100, Jonathan Cameron wrote:  
> 
> ...
> 
> > > > > +     /* Walk remaining bits of active_scan_mask */
> > > > > +     in_ind = find_next_bit(indio_dev->active_scan_mask, masklength,
> > > > > +                            in_ind + 1);  
> > > >
> > > > I wonder if it matters to check that in_ind + 1 is in fact lower than
> > > > masklength? Not that it will be an issue for find_next_bit() but we will
> > > > fail the expectation:
> > > >
> > > > if (unlikely(__start >= sz)) [1]
> > > >
> > > > And being this a sensible path, I thought it's worth (at least) questioning...  
> > >
> > > It doesn't matter. The find_*_bit() are all aligned to return sz for
> > > anything "not found anymore" cases, so it will be okay.  
> >
> > I know :):
> >
> > "...Not that it will be an issue for find_next_bit()..."
> >
> > I was mostly worried by performance as we'll have a compiler hint that
> > will pretty much fail (that ´if (unlikely(__start >= sz))' for every sample we push and
> > I guess the CPU will have to unroll that prediction. Maybe it will be smart enough to
> > adapt.  
> 
> Ah, I see now. Yeah, there might be a hint to skip the branch which is
> unlikely() for.

Assuming I remember how this all works...

This doesn't happen on the fast path (pushing samples)
It's a setup activity on a buffer being enabled.  The code is
generating a table of offsets and sizes that are then used to
on every sample.  So I don't think it's worth bothering to optimize it.

Jonathan

> 
> > But as I said, it might be neglectable but still worth at least
> > questioning...
> >  
> > > > Other than that kind of nit comment, patch looks good.
> > > >
> > > > [1]: https://elixir.bootlin.com/linux/v6.16/source/lib/find_bit.c#L50  
> > >  
> > > > > +     while (in_ind != masklength) {
> > > > > +             ret = iio_storage_bytes_for_si(indio_dev, in_ind);
> > > > > +             if (ret < 0)
> > > > > +                     goto error_clear_mux_table;
> > > > > +
> > > > > +             length = ret;
> > > > > +             /* Make sure we are aligned */
> > > > > +             in_loc = roundup(in_loc, length) + length;
> > > > > +             in_ind = find_next_bit(indio_dev->active_scan_mask,
> > > > > +                                    masklength, in_ind + 1);
> > > > > +     }  
> 


  reply	other threads:[~2025-08-06 15:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-02 17:15 [PATCH RFT] iio: Fix core buffer demux failure to account for unwanted channels at tail Jonathan Cameron
2025-08-03 19:46 ` Andy Shevchenko
2025-08-04 10:48   ` Jonathan Cameron
2025-08-04 12:52     ` Andy Shevchenko
2025-08-06 15:40       ` Jonathan Cameron
2025-08-04 15:38 ` Nuno Sá
2025-08-04 16:02   ` Andy Shevchenko
2025-08-05  8:16     ` Nuno Sá
2025-08-05 12:41       ` Andy Shevchenko
2025-08-06 15:36         ` Jonathan Cameron [this message]
2025-08-11  9:54           ` Nuno Sá

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=20250806163613.00003788@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=Jianping.Shen@de.bosch.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=noname.nuno@gmail.com \
    --cc=nuno.sa@analog.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox