* [PATCH] lib: flex_proportions.c: Remove some unused functions
@ 2014-12-20 14:40 Rickard Strandqvist
2015-01-05 8:45 ` Jan Kara
0 siblings, 1 reply; 3+ messages in thread
From: Rickard Strandqvist @ 2014-12-20 14:40 UTC (permalink / raw)
To: Tejun Heo, Jan Kara; +Cc: Rickard Strandqvist, David S. Miller, linux-kernel
Removes some functions that are not used anywhere:
prop_fraction_single() prop_local_destroy_single() prop_local_init_single() fprop_global_destroy()
This was partially found by using a static code analysis program called cppcheck.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
include/linux/flex_proportions.h | 6 -----
lib/flex_proportions.c | 46 --------------------------------------
2 files changed, 52 deletions(-)
diff --git a/include/linux/flex_proportions.h b/include/linux/flex_proportions.h
index 0d348e0..27ea6a1 100644
--- a/include/linux/flex_proportions.h
+++ b/include/linux/flex_proportions.h
@@ -34,7 +34,6 @@ struct fprop_global {
};
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);
/*
@@ -52,12 +51,7 @@ struct fprop_local_single {
{ .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)
diff --git a/lib/flex_proportions.c b/lib/flex_proportions.c
index 8f25652..575f9e1 100644
--- a/lib/flex_proportions.c
+++ b/lib/flex_proportions.c
@@ -47,11 +47,6 @@ int fprop_global_init(struct fprop_global *p, gfp_t gfp)
return 0;
}
-void fprop_global_destroy(struct fprop_global *p)
-{
- percpu_counter_destroy(&p->events);
-}
-
/*
* Declare @periods new periods. It is upto the caller to make sure period
* transitions cannot happen in parallel.
@@ -90,18 +85,6 @@ bool fprop_new_period(struct fprop_global *p, int periods)
* ---- 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)
{
@@ -134,35 +117,6 @@ void __fprop_inc_single(struct fprop_global *p, struct fprop_local_single *pl)
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 ----
*/
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lib: flex_proportions.c: Remove some unused functions
2014-12-20 14:40 [PATCH] lib: flex_proportions.c: Remove some unused functions Rickard Strandqvist
@ 2015-01-05 8:45 ` Jan Kara
2015-01-05 13:23 ` Tejun Heo
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2015-01-05 8:45 UTC (permalink / raw)
To: Rickard Strandqvist; +Cc: Tejun Heo, Jan Kara, David S. Miller, linux-kernel
On Sat 20-12-14 15:40:31, Rickard Strandqvist wrote:
> Removes some functions that are not used anywhere:
> prop_fraction_single() prop_local_destroy_single() prop_local_init_single() fprop_global_destroy()
>
> This was partially found by using a static code analysis program called cppcheck.
This is the same situation as with lib/proportions.c. The functions are
there for API completeness. As far as I'm looking the whole 'single'
section is unused so ifdeffing it out might make sense (and also ifdeffing
out fprop_inc_single() from include/linux/flex_proportions.h). Removing
fprop_global_destroy() is IMO pointless churn.
Honza
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
> include/linux/flex_proportions.h | 6 -----
> lib/flex_proportions.c | 46 --------------------------------------
> 2 files changed, 52 deletions(-)
>
> diff --git a/include/linux/flex_proportions.h b/include/linux/flex_proportions.h
> index 0d348e0..27ea6a1 100644
> --- a/include/linux/flex_proportions.h
> +++ b/include/linux/flex_proportions.h
> @@ -34,7 +34,6 @@ struct fprop_global {
> };
>
> 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);
>
> /*
> @@ -52,12 +51,7 @@ struct fprop_local_single {
> { .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)
> diff --git a/lib/flex_proportions.c b/lib/flex_proportions.c
> index 8f25652..575f9e1 100644
> --- a/lib/flex_proportions.c
> +++ b/lib/flex_proportions.c
> @@ -47,11 +47,6 @@ int fprop_global_init(struct fprop_global *p, gfp_t gfp)
> return 0;
> }
>
> -void fprop_global_destroy(struct fprop_global *p)
> -{
> - percpu_counter_destroy(&p->events);
> -}
> -
> /*
> * Declare @periods new periods. It is upto the caller to make sure period
> * transitions cannot happen in parallel.
> @@ -90,18 +85,6 @@ bool fprop_new_period(struct fprop_global *p, int periods)
> * ---- 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)
> {
> @@ -134,35 +117,6 @@ void __fprop_inc_single(struct fprop_global *p, struct fprop_local_single *pl)
> 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 ----
> */
> --
> 1.7.10.4
>
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lib: flex_proportions.c: Remove some unused functions
2015-01-05 8:45 ` Jan Kara
@ 2015-01-05 13:23 ` Tejun Heo
0 siblings, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2015-01-05 13:23 UTC (permalink / raw)
To: Jan Kara; +Cc: Rickard Strandqvist, David S. Miller, linux-kernel
On Mon, Jan 05, 2015 at 09:45:34AM +0100, Jan Kara wrote:
> On Sat 20-12-14 15:40:31, Rickard Strandqvist wrote:
> > Removes some functions that are not used anywhere:
> > prop_fraction_single() prop_local_destroy_single() prop_local_init_single() fprop_global_destroy()
> >
> > This was partially found by using a static code analysis program called cppcheck.
> This is the same situation as with lib/proportions.c. The functions are
> there for API completeness. As far as I'm looking the whole 'single'
> section is unused so ifdeffing it out might make sense (and also ifdeffing
> out fprop_inc_single() from include/linux/flex_proportions.h). Removing
> fprop_global_destroy() is IMO pointless churn.
I'll prolly use some of the now unused portion of the API to implement
per-memcg dirty ratio for cgroup writeback, so let's please leave it
alone for now.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-05 13:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-20 14:40 [PATCH] lib: flex_proportions.c: Remove some unused functions Rickard Strandqvist
2015-01-05 8:45 ` Jan Kara
2015-01-05 13:23 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).