Lines Matching refs:blkg
47 struct blkcg_gq *blkg;
68 /* is this blkg online? protected by both blkcg and q locks */
125 * A blkcg_gq (blkg) is association between a block cgroup (blkcg) and a
129 * There can be multiple active blkcg policies and each blkg:policy pair is
136 /* the blkg and policy id this per-policy data belongs to */
137 struct blkcg_gq *blkg;
201 const char *blkg_dev_name(struct blkcg_gq *blkg);
213 struct blkcg_gq *blkg;
223 * bio_issue_as_root_blkg - see if this bio needs to be issued as root blkg
224 * @return: true if this bio needs to be submitted with the root blkg context.
227 * it were attached to the root blkg, and then backcharge to the actual owning
228 * blkg. The idea is we do bio_blkcg_css() to look up the actual context for
229 * the bio and attach the appropriate blkg to the bio. Then we call this helper
230 * and if it is true run with the root blkg for that queue and then do any
239 * blkg_lookup - lookup blkg for the specified blkcg - q pair
243 * Lookup blkg for the @blkcg - @q pair.
250 struct blkcg_gq *blkg;
255 blkg = rcu_dereference_check(blkcg->blkg_hint,
257 if (blkg && blkg->q == q)
258 return blkg;
260 blkg = radix_tree_lookup(&blkcg->blkg_tree, q->id);
261 if (blkg && blkg->q != q)
262 blkg = NULL;
263 return blkg;
268 * @blkg: blkg of interest
271 * Return pointer to private data associated with the @blkg-@pol pair.
273 static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
276 return blkg ? blkg->pd[pol->plid] : NULL;
286 * pdata_to_blkg - get blkg associated with policy private data
289 * @pd is policy private data. Determine the blkg it's associated with.
293 return pd ? pd->blkg : NULL;
302 * blkg_path - format cgroup path of blkg
303 * @blkg: blkg of interest
307 * Format the path of the cgroup of @blkg into @buf.
309 static inline int blkg_path(struct blkcg_gq *blkg, char *buf, int buflen)
311 return cgroup_path(blkg->blkcg->css.cgroup, buf, buflen);
315 * blkg_get - get a blkg reference
316 * @blkg: blkg to get
320 static inline void blkg_get(struct blkcg_gq *blkg)
322 percpu_ref_get(&blkg->refcnt);
326 * blkg_tryget - try and get a blkg reference
327 * @blkg: blkg to get
329 * This is for use when doing an RCU lookup of the blkg. We may be in the midst
330 * of freeing this blkg, so we can only use it if the refcnt is not zero.
332 static inline bool blkg_tryget(struct blkcg_gq *blkg)
334 return blkg && percpu_ref_tryget(&blkg->refcnt);
338 * blkg_put - put a blkg reference
339 * @blkg: blkg to put
341 static inline void blkg_put(struct blkcg_gq *blkg)
343 percpu_ref_put(&blkg->refcnt);
347 * blkg_for_each_descendant_pre - pre-order walk of a blkg's descendants
350 * @p_blkg: target blkg to walk descendants of
364 * blkg_for_each_descendant_post - post-order walk of a blkg's descendants
367 * @p_blkg: target blkg to walk descendants of
383 static inline void blkcg_use_delay(struct blkcg_gq *blkg)
385 if (WARN_ON_ONCE(atomic_read(&blkg->use_delay) < 0))
387 if (atomic_add_return(1, &blkg->use_delay) == 1)
388 atomic_inc(&blkg->blkcg->css.cgroup->congestion_count);
391 static inline int blkcg_unuse_delay(struct blkcg_gq *blkg)
393 int old = atomic_read(&blkg->use_delay);
407 while (old && !atomic_try_cmpxchg(&blkg->use_delay, &old, old - 1))
413 atomic_dec(&blkg->blkcg->css.cgroup->congestion_count);
419 * @blkg: target blkg
426 static inline void blkcg_set_delay(struct blkcg_gq *blkg, u64 delay)
428 int old = atomic_read(&blkg->use_delay);
430 /* We only want 1 person setting the congestion count for this blkg. */
431 if (!old && atomic_try_cmpxchg(&blkg->use_delay, &old, -1))
432 atomic_inc(&blkg->blkcg->css.cgroup->congestion_count);
434 atomic64_set(&blkg->delay_nsec, delay);
439 * @blkg: target blkg
443 static inline void blkcg_clear_delay(struct blkcg_gq *blkg)
445 int old = atomic_read(&blkg->use_delay);
447 /* We only want 1 person clearing the congestion count for this blkg. */
448 if (old && atomic_try_cmpxchg(&blkg->use_delay, &old, 0))
449 atomic_dec(&blkg->blkcg->css.cgroup->congestion_count);
468 void blkcg_add_delay(struct blkcg_gq *blkg, u64 now, u64 delta);
493 static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
496 static inline char *blkg_path(struct blkcg_gq *blkg) { return NULL; }
497 static inline void blkg_get(struct blkcg_gq *blkg) { }
498 static inline void blkg_put(struct blkcg_gq *blkg) { }