linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: akpm@linux-foundation.org, jack@suse.cz, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] flex_proportions: remove unused fprop_local_single
Date: Fri, 19 Jan 2024 16:23:12 +0100	[thread overview]
Message-ID: <20240119152312.qb4xd43zw6jtdihv@quack3> (raw)
In-Reply-To: <20240118201321.759174-1-shikemeng@huaweicloud.com>

On Fri 19-01-24 04:13:21, Kemeng Shi wrote:
> The single variant of flex_proportions is not used. Simply remove it.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>

Yup. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  include/linux/flex_proportions.h | 32 -------------
>  lib/flex_proportions.c           | 77 --------------------------------
>  2 files changed, 109 deletions(-)
> 
> diff --git a/include/linux/flex_proportions.h b/include/linux/flex_proportions.h
> index 3e378b1fb0bc..e9a72fd0bfe7 100644
> --- a/include/linux/flex_proportions.h
> +++ b/include/linux/flex_proportions.h
> @@ -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 ----
>   */
> diff --git a/lib/flex_proportions.c b/lib/flex_proportions.c
> index 83332fefa6f4..84ecccddc771 100644
> --- a/lib/flex_proportions.c
> +++ b/lib/flex_proportions.c
> @@ -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 ----
>   */
> -- 
> 2.30.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR


      reply	other threads:[~2024-01-19 15:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-18 20:13 Kemeng Shi
2024-01-19 15:23 ` Jan Kara [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240119152312.qb4xd43zw6jtdihv@quack3 \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shikemeng@huaweicloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox