# Re: \[PATCH v14 1/6\] sched/core: uclamp: Extend CPU's cgroup controller

- From: Michal Koutný \<mkoutny@suse.com\>
- Date: 2019-09-03 08:53:00 
- List: linux-api
- Page: https://ratatoskr.run/linux-api/2019/09/5706754
- Thread: https://ratatoskr.run/cgroups/2019/08/5695641/t.md

```text
On Mon, Sep 02, 2019 at 04:02:57PM -0700, Suren Baghdasaryan [ref] wrote:
> > +static inline void cpu_uclamp_print(struct seq_file *sf,
> > +                                   enum uclamp_id clamp_id)
> > [...]
> > +       rcu_read_lock();
> > +       tg = css_tg(seq_css(sf));
> > +       util_clamp = tg->uclamp_req[clamp_id].value;
> > +       rcu_read_unlock();
> > +
> > +       if (util_clamp == SCHED_CAPACITY_SCALE) {
> > +               seq_puts(sf, "max\n");
> > +               return;
> > +       }
> > +
> > +       percent = tg->uclamp_pct[clamp_id];
> 
> You are taking RCU lock when accessing tg->uclamp_req but not when
> accessing tg->uclamp_pct.
Good point.

> Is that intentional? Can tg be destroyed under you?
Actually, the rcu_read{,un}lock should be unnecessary in the context of
the kernfs file op handler -- the tg/css won't go away as long as its
kernfs file is being worked with.

```

## Attachments

- [signature.asc](https://ratatoskr.run/linux-api/2019/09/5706754/attachment/0) (application/pgp-signature, 833 bytes)
