lkml.org 
[lkml]   [2023]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 16/18] timer: Implement the hierarchical pull model
On Wed, Mar 01, 2023 at 03:17:42PM +0100, Anna-Maria Behnsen wrote:
> +static bool tmigr_active_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;
> +
> + if (newstate.migrator == TMIGR_NONE) {
> + newstate.migrator = (u8)childmask;
> +
> + /* Changes need to be propagated */
> + walk_done = false;
> + }
> +
> + newstate.active |= (u8)childmask;
> +
> + newstate.seq++;
> +
> + if (atomic_cmpxchg(group->migr_state, curstate.state, newstate.state) != curstate.state) {
> + newstate.state = curstate.state = atomic_read(group->migr_state);
> + goto retry;
> + }

if (!atomic_try_cmpxchg(group->migr_state, &curstate.state, newstate.state)) {
newstate.state = curstate.state;
goto retry;
}

> +
> + if (group->parent && (walk_done == false)) {
> + data->groupstate.state = atomic_read(group->parent->migr_state);
> + data->childmask = group->childmask;
> + }
> +
> + /*
> + * Group is active, event will be ignored - bit is updated without
> + * holding the lock. In case bit is set while another CPU already
> + * handles remote events, nothing happens, because it is clear that
> + * CPU became active just in this moment, or in worst case event is
> + * handled remote. Nothing to worry about.
> + */
> + group->groupevt.ignore = 1;
> +
> + return walk_done;
> +}

\
 
 \ /
  Last update: 2023-03-27 01:11    [W:0.377 / U:0.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site