Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC4576ADF for ; Mon, 17 Jul 2023 05:59:10 +0000 (UTC) Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-314319c0d3eso4353287f8f.0 for ; Sun, 16 Jul 2023 22:59:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689573549; x=1692165549; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=XpZ7hzVo6aNRf/h0hvR1mJB9+o96DCCB7QWW+ufx0pU=; b=gsqGpIKM9mPZMzA3LvCcDIfoN8H/I4Adtj3sPVDR0Qugu4fhofW09QVzj5xI2qbeli 7z55hpCnuiekEYgeca3V5kND/jzJWvFjnYqtczmny22VjIqTff/DsFaO8dNjDi+x7gUu oMz3GifjMJ/pZrCiO8dYBWgAs2gG084ucLef+mUtQoBlo/zRBH28cQ1puIgmpdw1BQqr KzmJaU9HF9GGC43sUviMKUAwFx+jX6qEGK9expFsrA7U7V8OYuusZ9hICQZomrtlFkGk yuJdWwv1K+0nnSE4dgrpe49yImRCpvM9TIZdqcoZ+6LivSzUV0kwEP/dztk9zHYiUDeT mt9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689573549; x=1692165549; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XpZ7hzVo6aNRf/h0hvR1mJB9+o96DCCB7QWW+ufx0pU=; b=aYPG7o/hxlmeRlUuSEnOzM6Qh0DklKH8IWEyK7liLtflAO1VJS8S8gjn61Z6vq79PK ymHS4KdBx56hw/0jBAA8kvvzbSm/l8o9nRoCFvRw5yvNBsdeu5wK005zKkQFl6W09g0I 17LwVXRoac6/+T/elTJPTvaGGIPbVJg4yyMzi6sH/EPL3UlH4PD3GQiNKNCtqQQK4pWh VgFxDAkRQ7tf8DjRqOJabgGOgbpQ3deL/2iXY/FmJSCs/C6edJxPQrCsfR6zt1d5cM3T DHlUju1hJT4ZQY4deInLi+AVD09xAdT6E388uxmrlIeDTpwUvVnVh/uvtfP/UiJS+J/t sYtw== X-Gm-Message-State: ABy/qLY3PLW002zuiIgBC8VOearcqhsEMPJWQVGGjug9tTmvqe5OCWCa z+aYT6dfwudDdskushUEk2YGQQ== X-Google-Smtp-Source: APBJJlFAOsPnYfrYraYLXRFFOsywGCy5jChWoIeEJmfmfkbwoichwi2xYwRd3KwR3od1Luku3gg3ng== X-Received: by 2002:a05:6000:18cf:b0:315:a32d:311f with SMTP id w15-20020a05600018cf00b00315a32d311fmr9388489wrq.14.1689573548858; Sun, 16 Jul 2023 22:59:08 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id h7-20020a5d5487000000b0030ae901bc54sm18071409wrv.62.2023.07.16.22.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jul 2023 22:59:06 -0700 (PDT) Date: Mon, 17 Jul 2023 08:59:03 +0300 From: Dan Carpenter To: oe-kbuild@lists.linux.dev, Mingzhe Zou , colyli@suse.de, linux-bcache@vger.kernel.org Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev, bcache@lists.ewheeler.net, zoumingzhe@qq.com Subject: Re: [PATCH v3] bcache: Separate bch_moving_gc() from bch_btree_gc() Message-ID: <83e846fd-a4e5-4b89-8a22-ec4189335379@kadam.mountain> Precedence: bulk X-Mailing-List: oe-kbuild-all@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230629114740.311-1-mingzhe.zou@easystack.cn> Hi Mingzhe, kernel test robot noticed the following build warnings: https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Mingzhe-Zou/bcache-Separate-bch_moving_gc-from-bch_btree_gc/20230629-194834 base: linus/master patch link: https://lore.kernel.org/r/20230629114740.311-1-mingzhe.zou%40easystack.cn patch subject: [PATCH v3] bcache: Separate bch_moving_gc() from bch_btree_gc() config: x86_64-randconfig-m001-20230710 (https://download.01.org/0day-ci/archive/20230716/202307160359.0vHG3r40-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce: (https://download.01.org/0day-ci/archive/20230716/202307160359.0vHG3r40-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Reported-by: Dan Carpenter | Closes: https://lore.kernel.org/r/202307160359.0vHG3r40-lkp@intel.com/ New smatch warnings: drivers/md/bcache/btree.c:1887 moving_gc_should_run() error: uninitialized symbol 'used_sectors'. Old smatch warnings: drivers/md/bcache/btree.c:1535 btree_gc_rewrite_node() error: 'n' dereferencing possible ERR_PTR() drivers/md/bcache/btree.c:1551 btree_gc_rewrite_node() error: 'n' dereferencing possible ERR_PTR() vim +/used_sectors +1887 drivers/md/bcache/btree.c 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1856 static bool moving_gc_should_run(struct cache_set *c) 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1857 { 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1858 struct bucket *b; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1859 struct cache *ca = c->cache; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1860 size_t moving_gc_threshold = ca->sb.bucket_size >> 2, frag_percent; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1861 unsigned long used_buckets = 0, frag_buckets = 0, move_buckets = 0; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1862 unsigned long dirty_sectors = 0, frag_sectors, used_sectors; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1863 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1864 if (c->gc_stats.in_use > bch_cutoff_writeback_sync) 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1865 return true; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1866 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1867 mutex_lock(&c->bucket_lock); 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1868 for_each_bucket(b, ca) { 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1869 if (GC_MARK(b) != GC_MARK_DIRTY) 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1870 continue; Smatch is complaining that we might not enter the loop or there could be no GC_MARK_DIRTY entries. 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1871 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1872 used_buckets++; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1873 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1874 used_sectors = GC_SECTORS_USED(b); 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1875 dirty_sectors += used_sectors; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1876 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1877 if (used_sectors < ca->sb.bucket_size) 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1878 frag_buckets++; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1879 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1880 if (used_sectors <= moving_gc_threshold) 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1881 move_buckets++; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1882 } 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1883 mutex_unlock(&c->bucket_lock); 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1884 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1885 c->fragment_nbuckets = frag_buckets; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1886 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 @1887 if (used_sectors < c->nbuckets * bch_cutoff_writeback / 100) It's sort of weird that we are using the used_sectors value from the last MARK_DIRTY iteration through the loop. Should it be used_buckets? 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1888 return false; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1889 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1890 if (move_buckets > ca->heap.size) 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1891 return true; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1892 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1893 frag_sectors = used_buckets * ca->sb.bucket_size - dirty_sectors; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1894 frag_percent = div_u64(frag_sectors * 100, ca->sb.bucket_size * c->nbuckets); 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1895 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1896 if (frag_percent >= COPY_GC_PERCENT) 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1897 return true; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1898 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1899 if (used_sectors > c->nbuckets * bch_cutoff_writeback_sync / 100) 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1900 return true; 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1901 4b0cf76f1e36e7 Mingzhe Zou 2023-06-29 1902 return false; cafe563591446c Kent Overstreet 2013-03-23 1903 } -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki