Received: by 10.192.165.148 with SMTP id m20csp4514133imm; Mon, 30 Apr 2018 21:20:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpnV0A1OQiQ7p8Rsl8Ek3nLugTKWT+r6dzTFDhJi32cvkV5SYKpQRmRCWohfeogXEBm7szH X-Received: by 2002:a63:7c01:: with SMTP id x1-v6mr11871409pgc.286.1525148422420; Mon, 30 Apr 2018 21:20:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525148422; cv=none; d=google.com; s=arc-20160816; b=P5uQ9TYSmpZh4OUR9VmPIgBjzVy3mYNvTHZf1s3VEMrAm1qQI3g7R1GHC/mMLgjoAe TNWALaFw9qSQtwNWcLvKd3ipNLs/WsIs96VHT5QU6dbHbZgXTld6MO5H1VPvSgC3VDIl KNj3WpPAvzfghUl+Zda58Nz14v2+drFJJ6XHXzKhnvcASQQ2c/lTu61klscFEVQWTRE/ 6C0vHS9K7Y3RFYO+QG0rL6qbC3uS7lC5KdcfxWKf1pQiGY4/YXUVMwekG58c/v0aENTP hNyfFMg1NKNFSTFC85hawnWMa+Pah8Z/BdVNGhoZuUWZQTWE0ZzTfA9yOyIYg8ftFyqY w2Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=kQcj8HzfpFOZeNow1lMPdVPrlwlVmy9Iicb+gSwgdhA=; b=NoxzeRRNCi908XnzbQTeZYW9zOeQiPBih7SpE9q/Mi6XE0YeNHh0od+GXG5dMGN2tw Ram3T4TBiv9iA4vapTUrAgeLR89BUxOFmh4GXW3C0bYCP//ixzvgOCTBkBKX2muT2g4f 3I97wO90+EgCMMYcZ9ZZK0p5irloo3l016jf4essMBaMoyiWEv6NA5XwZn/72Koo77Jb RxIpjR2kDW2c9K/ILZQSJhJXIsU0sFRp777bRREOTVfOgfuXPGhL3ofpq/gBY2CdLPDp 9y5pODqL3gg5l5C6WTy/uvQ2jw6LtQdJ1xjI6B4yHRsGHt3OnItsCOc0rhnTt2xfKo2G he1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f96-v6si8718125plb.418.2018.04.30.21.20.05; Mon, 30 Apr 2018 21:20:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750984AbeEAET5 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 1 May 2018 00:19:57 -0400 Received: from mga04.intel.com ([192.55.52.120]:31548 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750808AbeEAET4 (ORCPT ); Tue, 1 May 2018 00:19:56 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Apr 2018 21:19:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,349,1520924400"; d="scan'208";a="54962337" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga002.jf.intel.com with ESMTP; 30 Apr 2018 21:19:55 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 30 Apr 2018 21:19:55 -0700 Received: from FMSMSX109.amr.corp.intel.com ([169.254.15.12]) by fmsmsx117.amr.corp.intel.com ([169.254.3.69]) with mapi id 14.03.0319.002; Mon, 30 Apr 2018 21:19:54 -0700 From: "Dilger, Andreas" To: NeilBrown CC: "Drokin, Oleg" , Greg Kroah-Hartman , James Simmons , "Linux Kernel Mailing List" , Lustre Development List Subject: Re: [PATCH 03/10] staging: lustre: lu_object: discard extra lru count. Thread-Topic: [PATCH 03/10] staging: lustre: lu_object: discard extra lru count. Thread-Index: AQHT4P/2AaK69p/2O0ySpUfCQOIv8KQauqeA Date: Tue, 1 May 2018 04:19:54 +0000 Message-ID: References: <152514658325.17843.11455067361317157487.stgit@noble> <152514675893.17843.8396665070911641266.stgit@noble> In-Reply-To: <152514675893.17843.8396665070911641266.stgit@noble> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.252.137.157] Content-Type: text/plain; charset="us-ascii" Content-ID: <8CBB530FEF2EA04D8B612C526B2B58BC@intel.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Apr 30, 2018, at 21:52, NeilBrown 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 Looks reasonable, though it would also be possible to fix the percpu functions rather than adding a workaround in this code. Reviewed-by: Andreas Dilger > --- > 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 > > 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