lkml.org 
[lkml]   [2021]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH 3/8] scsi: ufshpb: Add region's reads counter
Date
> >
> > + if (ufshpb_mode == HPB_HOST_CONTROL)
> > + reads = atomic64_inc_return(&rgn->reads);
> > +
> > if (!ufshpb_is_support_chunk(transfer_len))
> > return;
> >
> > + if (ufshpb_mode == HPB_HOST_CONTROL) {
> > + /*
> > + * in host control mode, reads are the main source for
> > + * activation trials.
> > + */
> > + if (reads == ACTIVATION_THRSHLD) {
Oops - this is a bug...

> > +
> > + /* region reads - for host mode */
> > + atomic64_t reads;
>
> Why do you need an atomic variable for this? What are you trying to
> "protect" here by flushing the cpus all the time? What protects this
> variable from changing right after you have read from it (hint, you do
> that above...)
>
> atomics are not race-free, use a real lock if you need that.
We are on the data path here - this is called from queuecommand.
The "reads" counter is being symmetrically read and written,
so adding a spin lock here might become a source for contention.

Also I am not worried about the exact value of this counter, except of one place -
See above. Will fix it.

Thanks,
Avri
\
 
 \ /
  Last update: 2021-01-31 08:29    [W:0.045 / U:2.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site