CCSM Internals

Contents:

Data Structures

ccsm_master_list

List of all ccsm sets

Protected by ccsm_mutex and RCU

ccsm_name_table

Hash table that indexes sets by name

Hash table size is constant, indexing into the table requires no CC

The list in each table index is protected by ccsm_mutex and RCU

ccsm_id_table

Hash table that indexes sets by id

Hash table size is constant, indexing into the table requires no CC

The list in each table index is protected by ccsm_mutex and RCU

struct ccsm_set

unsigned int              flags;
char                      name[CCSM_MAX_NAME_LEN + 1];

unsigned int              type;
unsigned int              id;
void                     *handle;

struct list_head          members;
struct list_head          memberships;

struct list_head          call_backs;

struct list_head          name_table_entry;
struct list_head          id_table_entry;
struct list_head          master_entry;

struct kref               kref;
  • flags

  • type

  • id

  • handle

  • members - List of members. ccsm_mutex & RCU

  • memberships - List of sets that this set is a member of. ccsm_mutex & RCU

  • call_backs - Callbacks registered for this set. Protected by

    ccsm_mutex only. No RCU.

  • name_table_entry - Entry in name table. Same CC as name table.

  • id_table_entry - Entry in id table. Same CC as id table.

  • master_entry - Entry on master list. Same CC as master list.

  • kref - Reference count for this set. A reference is kept by the

    framework when the set is created. The framework reference is released when ccsm_destroy_set is called and the set is freed when the reference count goes to 0.

struct ccsm_member

struct ccsm_set *owner;
struct list_head owner_entry;

struct ccsm_set *set;
struct list_head set_entry;
  • owner - Set that this member is in. Constant.
  • owner_entry - Entry on members list. ccsm_mutex & RCU
  • set - Set that this member represents. Constant.
  • set_entry - Entry on memberships list. ccsm_mutex & RCU

Concurrency Control

ccsm_mutex

It is a lock global to CCSM

Protects write access to all lists, as a group, in CCSM

protects read and write access for call_backs list on ccsm_set struct

RCU

Used globally for CCSM as a whole

indicated by the fact that there is one write mutex(ccsm_mutex) for all of ccsm under RCU

Protects read access for CCSM lists

while peremitting multiple readers

RCU only used for list operations

list_add_rcu

list_del_rcu

must synchronize_rcu or call_rcu before kfree

list_for_each_entry_rcu

atomic types

Each CCSM type has a different atomic counter.

CCSM types are used to represent different types of objects managed by CCSM

the ability to generate unique names for each type when no explicit name is assigned is useful

CCSM uses the counters to generate unique names

Every name atomicly increments and reads the counter

Must be used with atomic ops

atomic_inc_return

callbacks

All callbacks execute with the ccsm_mutex acquired

FIXME: Can we remove this restriction using RCU?

Lock acquisition order for subsystems using CCSM callbacks must thus take into account the fact that CCSM mutex will already be held when callbacks are invoked

For example

group scheduling thus assumes ccsm_mutex must be held before gsched_lock everywhere since this is inevitably true for the group scheduilng routines registered as CCSM callbacks

Indices and tables