LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: "Dilger\, Andreas" <andreas.dilger@intel.com>
Cc: "Drokin\, Oleg" <oleg.drokin@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	James Simmons <jsimmons@infradead.org>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	Lustre Development List <lustre-devel@lists.lustre.org>
Subject: Re: [PATCH 03/10] staging: lustre: lu_object: discard extra lru count.
Date: Fri, 04 May 2018 10:08:35 +1000	[thread overview]
Message-ID: <87k1skffjw.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <A3CD6D51-5ADF-41A0-AED2-B1C06935586C@intel.com>

[-- Attachment #1: Type: text/plain, Size: 5366 bytes --]

On Tue, May 01 2018, Dilger, Andreas wrote:

> On Apr 30, 2018, at 21:52, NeilBrown <neilb@suse.com> wrote:
>> 
>> lu_object maintains 2 lru counts.
>> One is a per-bucket lsb_lru_len.
>> The other is the per-cpu ls_lru_len_counter.
>> 
>> The only times the per-bucket counters are use are:
>> - a debug message when an object is added
>> - in lu_site_stats_get when all the counters are combined.
>> 
>> The debug message is not essential, and the per-cpu counter
>> can be used to get the combined total.
>> 
>> So discard the per-bucket lsb_lru_len.
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>
> Looks reasonable, though it would also be possible to fix the percpu
> functions rather than adding a workaround in this code.

It would be possibly to change percpu_counter_read_positive() to
take a const (and we should), but thanks to you highlighting this
I realized that I should be using percpu_counter_sum_positive(),
to read across all per-cpu counters.  That takes a spinlock
so it would be a much harder sell to get it to accept a
const pointer.

Thanks,
NeilBrown


>
> Reviewed-by: Andreas Dilger <andreas.dilger@dilger.ca>
>
>> ---
>> drivers/staging/lustre/lustre/obdclass/lu_object.c |   24 ++++++++------------
>> 1 file changed, 9 insertions(+), 15 deletions(-)
>> 
>> diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
>> index 2a8a25d6edb5..2bf089817157 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
>> @@ -57,10 +57,6 @@
>> #include <linux/list.h>
>> 
>> struct lu_site_bkt_data {
>> -	/**
>> -	 * number of object in this bucket on the lsb_lru list.
>> -	 */
>> -	long			lsb_lru_len;
>> 	/**
>> 	 * LRU list, updated on each access to object. Protected by
>> 	 * bucket lock of lu_site::ls_obj_hash.
>> @@ -187,10 +183,9 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o)
>> 	if (!lu_object_is_dying(top)) {
>> 		LASSERT(list_empty(&top->loh_lru));
>> 		list_add_tail(&top->loh_lru, &bkt->lsb_lru);
>> -		bkt->lsb_lru_len++;
>> 		percpu_counter_inc(&site->ls_lru_len_counter);
>> -		CDEBUG(D_INODE, "Add %p to site lru. hash: %p, bkt: %p, lru_len: %ld\n",
>> -		       o, site->ls_obj_hash, bkt, bkt->lsb_lru_len);
>> +		CDEBUG(D_INODE, "Add %p to site lru. hash: %p, bkt: %p\n",
>> +		       o, site->ls_obj_hash, bkt);
>> 		cfs_hash_bd_unlock(site->ls_obj_hash, &bd, 1);
>> 		return;
>> 	}
>> @@ -238,7 +233,6 @@ void lu_object_unhash(const struct lu_env *env, struct lu_object *o)
>> 
>> 			list_del_init(&top->loh_lru);
>> 			bkt = cfs_hash_bd_extra_get(obj_hash, &bd);
>> -			bkt->lsb_lru_len--;
>> 			percpu_counter_dec(&site->ls_lru_len_counter);
>> 		}
>> 		cfs_hash_bd_del_locked(obj_hash, &bd, &top->loh_hash);
>> @@ -422,7 +416,6 @@ int lu_site_purge_objects(const struct lu_env *env, struct lu_site *s,
>> 			cfs_hash_bd_del_locked(s->ls_obj_hash,
>> 					       &bd2, &h->loh_hash);
>> 			list_move(&h->loh_lru, &dispose);
>> -			bkt->lsb_lru_len--;
>> 			percpu_counter_dec(&s->ls_lru_len_counter);
>> 			if (did_sth == 0)
>> 				did_sth = 1;
>> @@ -621,7 +614,6 @@ static struct lu_object *htable_lookup(struct lu_site *s,
>> 		lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_HIT);
>> 		if (!list_empty(&h->loh_lru)) {
>> 			list_del_init(&h->loh_lru);
>> -			bkt->lsb_lru_len--;
>> 			percpu_counter_dec(&s->ls_lru_len_counter);
>> 		}
>> 		return lu_object_top(h);
>> @@ -1834,19 +1826,21 @@ struct lu_site_stats {
>> 	unsigned int	lss_busy;
>> };
>> 
>> -static void lu_site_stats_get(struct cfs_hash *hs,
>> +static void lu_site_stats_get(const struct lu_site *s,
>> 			      struct lu_site_stats *stats, int populated)
>> {
>> +	struct cfs_hash *hs = s->ls_obj_hash;
>> 	struct cfs_hash_bd bd;
>> 	unsigned int i;
>> +	/* percpu_counter_read_positive() won't accept a const pointer */
>> +	struct lu_site *s2 = (struct lu_site *)s;
>
> It would seem worthwhile to change the percpu_counter_read_positive() and
> percpu_counter_read() arguments to be "const struct percpu_counter *fbc",
> rather than doing this cast here.  I can't see any reason that would be bad,
> since both implementations just access fbc->count, and do not modify anything.
>
>> +	stats->lss_busy += cfs_hash_size_get(hs) -
>> +		percpu_counter_read_positive(&s2->ls_lru_len_counter);
>> 	cfs_hash_for_each_bucket(hs, &bd, i) {
>> -		struct lu_site_bkt_data *bkt = cfs_hash_bd_extra_get(hs, &bd);
>> 		struct hlist_head	*hhead;
>> 
>> 		cfs_hash_bd_lock(hs, &bd, 1);
>> -		stats->lss_busy  +=
>> -			cfs_hash_bd_count_get(&bd) - bkt->lsb_lru_len;
>> 		stats->lss_total += cfs_hash_bd_count_get(&bd);
>> 		stats->lss_max_search = max((int)stats->lss_max_search,
>> 					    cfs_hash_bd_depmax_get(&bd));
>> @@ -2039,7 +2033,7 @@ int lu_site_stats_print(const struct lu_site *s, struct seq_file *m)
>> 	struct lu_site_stats stats;
>> 
>> 	memset(&stats, 0, sizeof(stats));
>> -	lu_site_stats_get(s->ls_obj_hash, &stats, 1);
>> +	lu_site_stats_get(s, &stats, 1);
>> 
>> 	seq_printf(m, "%d/%d %d/%ld %d %d %d %d %d %d %d\n",
>> 		   stats.lss_busy,
>> 
>> 
>
> Cheers, Andreas
> --
> Andreas Dilger
> Lustre Principal Architect
> Intel Corporation

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2018-05-04  0:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-01  3:52 [PATCH 00/10] staging: lustre: assorted improvements NeilBrown
2018-05-01  3:52 ` [PATCH 02/10] staging: lustre: make struct lu_site_bkt_data private NeilBrown
2018-05-01  4:10   ` [lustre-devel] " Dilger, Andreas
2018-05-02  3:02   ` James Simmons
2018-05-03 23:39     ` NeilBrown
2018-05-07  1:42       ` Greg Kroah-Hartman
2018-05-01  3:52 ` [PATCH 01/10] staging: lustre: ldlm: store name directly in namespace NeilBrown
2018-05-01  4:04   ` Dilger, Andreas
2018-05-02 18:11   ` James Simmons
2018-05-01  3:52 ` [PATCH 03/10] staging: lustre: lu_object: discard extra lru count NeilBrown
2018-05-01  4:19   ` Dilger, Andreas
2018-05-04  0:08     ` NeilBrown [this message]
2018-05-01  3:52 ` [PATCH 07/10] staging: lustre: llite: remove redundant lookup in dump_pgcache NeilBrown
2018-05-01  3:52 ` [PATCH 08/10] staging: lustre: move misc-device registration closer to related code NeilBrown
2018-05-02 18:12   ` James Simmons
2018-05-01  3:52 ` [PATCH 04/10] staging: lustre: lu_object: move retry logic inside htable_lookup NeilBrown
2018-05-01  8:22   ` [lustre-devel] " Dilger, Andreas
2018-05-02 18:21     ` James Simmons
2018-05-04  0:30       ` NeilBrown
2018-05-04  1:30     ` NeilBrown
2018-05-01  3:52 ` [PATCH 05/10] staging: lustre: fold lu_object_new() into lu_object_find_at() NeilBrown
2018-05-01  3:52 ` [PATCH 10/10] staging: lustre: fix error deref in ll_splice_alias() NeilBrown
2018-05-02  3:05   ` James Simmons
2018-05-04  0:34     ` NeilBrown
2018-05-01  3:52 ` [PATCH 06/10] staging: lustre: llite: use more private data in dump_pgcache NeilBrown
2018-05-01  3:52 ` [PATCH 09/10] staging: lustre: move remaining code from linux-module.c to module.c NeilBrown
2018-05-02 18:13   ` James Simmons
2018-05-07  0:54 [PATCH 00/10 - v2] staging: lustre: assorted improvements NeilBrown
2018-05-07  0:54 ` [PATCH 03/10] staging: lustre: lu_object: discard extra lru count NeilBrown

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=87k1skffjw.fsf@notabene.neil.brown.name \
    --to=neilb@suse.com \
    --cc=andreas.dilger@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jsimmons@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.org \
    --cc=oleg.drokin@intel.com \
    --subject='Re: [PATCH 03/10] staging: lustre: lu_object: discard extra lru count.' \
    /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

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).