lkml.org 
[lkml]   [2022]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 14/16] timer: Implement the hierarchical pull model
On Fri, Nov 04, 2022 at 03:57:35PM +0100, Anna-Maria Behnsen wrote:
> +static bool tmigr_inactive_up(struct tmigr_group *group,
> + struct tmigr_group *child,
> + void *ptr)
> +{
> + union tmigr_state curstate, newstate;
> + struct tmigr_walk *data = ptr;
> + bool walk_done;
> + u32 childmask;
> +
> + childmask = data->childmask;
> + newstate = curstate = data->groupstate;
> +
> +retry:
> + walk_done = true;
> +
> + /* Reset active bit when child is no longer active */
> + if (!data->childstate.active)
> + newstate.active &= ~(u8)childmask;
> +
> + if (newstate.migrator == (u8)childmask) {
> + /*
> + * Find a new migrator for the group, because child group
> + * is idle!
> + */
> + if (!data->childstate.active) {
> + unsigned long new_migr_bit, active = newstate.active;
> +
> + new_migr_bit = find_first_bit(&active, BIT_CNT);
> +
> + /* Changes need to be propagated */
> + walk_done = false;
> + data->childmask = group->childmask;
> +
> + if (new_migr_bit != BIT_CNT)
> + newstate.migrator = BIT(new_migr_bit);
> + else
> + newstate.migrator = TMIGR_NONE;
> + }
> + }
> +
> + newstate.seq++;
> +
> + DBG_BUG_ON((newstate.migrator != TMIGR_NONE) && !(newstate.active));
> +
> + if (atomic_cmpxchg(group->migr_state, curstate.state, newstate.state) != curstate.state) {
> + /*
> + * Something changed in child/parent group in the meantime,
> + * reread the state of child and parent; Update of
> + * data->childstate is required for event handling;
> + */
> + if (child)
> + data->childstate.state = atomic_read(child->migr_state);
> + newstate.state = curstate.state = atomic_read(group->migr_state);
> +
> + goto retry;
> + }
> +
> + data->groupstate = newstate;
> +
> + /* Event Handling */
> + tmigr_update_events(group, child, data);
> +
> + if (group->parent && (walk_done == false)) {

Nit: it would be slightly clearer if data->childmask were updated here.

> + data->childstate = newstate;
> + data->groupstate.state = atomic_read(group->parent->migr_state);

Thanks.

\
 
 \ /
  Last update: 2022-11-08 12:49    [W:1.739 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site