mbox series

[v4,0/9] Add Host control mode to HPB

Message ID 20210226083300.30934-1-avri.altman@wdc.com (mailing list archive)
Headers show
Series Add Host control mode to HPB | expand

Message

Avri Altman Feb. 26, 2021, 8:32 a.m. UTC
v3 -> v4:
 - rebase on Daejun's v25

v2 -> v3:
 - Attend Greg's and Can's comments
 - rebase on Daejun's v21

v1 -> v2:
 - attend Greg's and Daejun's comments
 - add patch 9 making host mode parameters configurable
 - rebase on Daejun's v19


The HPB spec defines 2 control modes - device control mode and host
control mode. In oppose to device control mode, in which the host obey
to whatever recommendation received from the device - In host control
mode, the host uses its own algorithms to decide which regions should
be activated or inactivated.

We kept the host managed heuristic simple and concise.

Aside from adding a by-spec functionality, host control mode entails
some further potential benefits: makes the hpb logic transparent and
readable, while allow tuning / scaling its various parameters, and
utilize system-wide info to optimize HPB potential.

This series is based on Samsung's V25 device-control HPB2.0 driver, see
msg-id: 20210226073233epcms2p80fca2dffabea03143a9414838f757633@epcms2p8
in lore.kernel.org.

This version was tested on Galaxy S20, and Xiaomi Mi10 pro.
Your meticulous review and testing is mostly welcome and appreciated.

Thanks,
Avri


Avri Altman (9):
  scsi: ufshpb: Cache HPB Control mode on init
  scsi: ufshpb: Add host control mode support to rsp_upiu
  scsi: ufshpb: Add region's reads counter
  scsi: ufshpb: Make eviction depends on region's reads
  scsi: ufshpb: Region inactivation in host mode
  scsi: ufshpb: Add hpb dev reset response
  scsi: ufshpb: Add "Cold" regions timer
  scsi: ufshpb: Add support for host control mode
  scsi: ufshpb: Make host mode parameters configurable

 Documentation/ABI/testing/sysfs-driver-ufs |  67 +++
 drivers/scsi/ufs/ufshcd.h                  |   2 +
 drivers/scsi/ufs/ufshpb.c                  | 528 ++++++++++++++++++++-
 drivers/scsi/ufs/ufshpb.h                  |  40 ++
 4 files changed, 613 insertions(+), 24 deletions(-)

Comments

Avri Altman March 2, 2021, 8:45 a.m. UTC | #1
> 
> Hi Avri,
> 
> > +static void ufshpb_read_to_handler(struct work_struct *work)
> > +{
> > +        struct delayed_work *dwork = to_delayed_work(work);
> > +        struct ufshpb_lu *hpb;
> > +        struct victim_select_info *lru_info;
> > +        struct ufshpb_region *rgn;
> > +        unsigned long flags;
> > +        LIST_HEAD(expired_list);
> > +
> > +        hpb = container_of(dwork, struct ufshpb_lu, ufshpb_read_to_work);
> > +
> > +        if (test_and_set_bit(TIMEOUT_WORK_PENDING, &hpb-
> >work_data_bits))
> > +                return;
> > +
> > +        spin_lock_irqsave(&hpb->rgn_state_lock, flags);
> > +
> > +        lru_info = &hpb->lru_info;
> > +
> > +        list_for_each_entry(rgn, &lru_info->lh_lru_rgn, list_lru_rgn) {
> > +                bool timedout = ktime_after(ktime_get(), rgn->read_timeout);
> > +
> > +                if (timedout) {
> 
> It is important not just to check the timeout, but how much time has passed.
> If the time exceeded is twice the threshold, the read_timeout_expiries
> value should be reduced by 2 instead of 1.
Theoretically this shouldn't happened.
Please note that POLLING_INTERVAL_MS << READ_TO_MS.
Better add appropriate check when making those configurable.

Thanks,
Avri
> 
> > +                        rgn->read_timeout_expiries--;
> 
> Thanks,
> Daejun
Avri Altman March 2, 2021, 8:51 a.m. UTC | #2
> Hi Avri,
> 
> > diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c
> > index cf704b82e72a..f33aa28e0a0a 100644
> > --- a/drivers/scsi/ufs/ufshpb.c
> > +++ b/drivers/scsi/ufs/ufshpb.c
> > @@ -642,7 +642,8 @@ int ufshpb_prep(struct ufs_hba *hba, struct
> ufshcd_lrb *lrbp)
> >                  if (rgn->reads == ACTIVATION_THRESHOLD)
> >                          activate = true;
> >                  spin_unlock_irqrestore(&rgn->rgn_lock, flags);
> > -                if (activate) {
> > +                if (activate ||
> > +                    test_and_clear_bit(RGN_FLAG_UPDATE, &rgn->rgn_flags)) {
> 
> How about merge rgn->rgn_flags to rgn_state?
Done.

Thanks,
Avri

> 
> Thanks,
> Daejun
Daejun Park March 2, 2021, 9:04 a.m. UTC | #3
Hi Avri,
> > 
> > Hi Avri,
> > 
> > > +static void ufshpb_read_to_handler(struct work_struct *work)
> > > +{
> > > +        struct delayed_work *dwork = to_delayed_work(work);
> > > +        struct ufshpb_lu *hpb;
> > > +        struct victim_select_info *lru_info;
> > > +        struct ufshpb_region *rgn;
> > > +        unsigned long flags;
> > > +        LIST_HEAD(expired_list);
> > > +
> > > +        hpb = container_of(dwork, struct ufshpb_lu, ufshpb_read_to_work);
> > > +
> > > +        if (test_and_set_bit(TIMEOUT_WORK_PENDING, &hpb-
> > >work_data_bits))
> > > +                return;
> > > +
> > > +        spin_lock_irqsave(&hpb->rgn_state_lock, flags);
> > > +
> > > +        lru_info = &hpb->lru_info;
> > > +
> > > +        list_for_each_entry(rgn, &lru_info->lh_lru_rgn, list_lru_rgn) {
> > > +                bool timedout = ktime_after(ktime_get(), rgn->read_timeout);
> > > +
> > > +                if (timedout) {
> > 
> > It is important not just to check the timeout, but how much time has passed.
> > If the time exceeded is twice the threshold, the read_timeout_expiries
> > value should be reduced by 2 instead of 1.
> Theoretically this shouldn't happened.
> Please note that POLLING_INTERVAL_MS << READ_TO_MS.
> Better add appropriate check when making those configurable.

OK, I agree.

Thanks,
Daejun

>  
> Thanks,
> Avri
> > 
> > > +                        rgn->read_timeout_expiries--;
> > 
> > Thanks,
> > Daejun
>  
>  
>  
>