Skip to content

Commit

Permalink
flex_proportions: remove unused fprop_local_single
Browse files Browse the repository at this point in the history
The single variant of flex_proportions is not used.  Simply remove it.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Kemeng Shi <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Kemeng Shi authored and akpm00 committed Feb 22, 2024
1 parent 0e02ca2 commit d6bbab8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 109 deletions.
32 changes: 0 additions & 32 deletions include/linux/flex_proportions.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,6 @@ int fprop_global_init(struct fprop_global *p, gfp_t gfp);
void fprop_global_destroy(struct fprop_global *p);
bool fprop_new_period(struct fprop_global *p, int periods);

/*
* ---- SINGLE ----
*/
struct fprop_local_single {
/* the local events counter */
unsigned long events;
/* Period in which we last updated events */
unsigned int period;
raw_spinlock_t lock; /* Protect period and numerator */
};

#define INIT_FPROP_LOCAL_SINGLE(name) \
{ .lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \
}

int fprop_local_init_single(struct fprop_local_single *pl);
void fprop_local_destroy_single(struct fprop_local_single *pl);
void __fprop_inc_single(struct fprop_global *p, struct fprop_local_single *pl);
void fprop_fraction_single(struct fprop_global *p,
struct fprop_local_single *pl, unsigned long *numerator,
unsigned long *denominator);

static inline
void fprop_inc_single(struct fprop_global *p, struct fprop_local_single *pl)
{
unsigned long flags;

local_irq_save(flags);
__fprop_inc_single(p, pl);
local_irq_restore(flags);
}

/*
* ---- PERCPU ----
*/
Expand Down
77 changes: 0 additions & 77 deletions lib/flex_proportions.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,83 +83,6 @@ bool fprop_new_period(struct fprop_global *p, int periods)
return true;
}

/*
* ---- SINGLE ----
*/

int fprop_local_init_single(struct fprop_local_single *pl)
{
pl->events = 0;
pl->period = 0;
raw_spin_lock_init(&pl->lock);
return 0;
}

void fprop_local_destroy_single(struct fprop_local_single *pl)
{
}

static void fprop_reflect_period_single(struct fprop_global *p,
struct fprop_local_single *pl)
{
unsigned int period = p->period;
unsigned long flags;

/* Fast path - period didn't change */
if (pl->period == period)
return;
raw_spin_lock_irqsave(&pl->lock, flags);
/* Someone updated pl->period while we were spinning? */
if (pl->period >= period) {
raw_spin_unlock_irqrestore(&pl->lock, flags);
return;
}
/* Aging zeroed our fraction? */
if (period - pl->period < BITS_PER_LONG)
pl->events >>= period - pl->period;
else
pl->events = 0;
pl->period = period;
raw_spin_unlock_irqrestore(&pl->lock, flags);
}

/* Event of type pl happened */
void __fprop_inc_single(struct fprop_global *p, struct fprop_local_single *pl)
{
fprop_reflect_period_single(p, pl);
pl->events++;
percpu_counter_add(&p->events, 1);
}

/* Return fraction of events of type pl */
void fprop_fraction_single(struct fprop_global *p,
struct fprop_local_single *pl,
unsigned long *numerator, unsigned long *denominator)
{
unsigned int seq;
s64 num, den;

do {
seq = read_seqcount_begin(&p->sequence);
fprop_reflect_period_single(p, pl);
num = pl->events;
den = percpu_counter_read_positive(&p->events);
} while (read_seqcount_retry(&p->sequence, seq));

/*
* Make fraction <= 1 and denominator > 0 even in presence of percpu
* counter errors
*/
if (den <= num) {
if (num)
den = num;
else
den = 1;
}
*denominator = den;
*numerator = num;
}

/*
* ---- PERCPU ----
*/
Expand Down

0 comments on commit d6bbab8

Please sign in to comment.