From: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
To: "idryomov@gmail.com" <idryomov@gmail.com>,
Alex Markuze <amarkuze@redhat.com>,
"dan.carpenter@linaro.org" <dan.carpenter@linaro.org>
Cc: "ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>,
"sage@inktank.com" <sage@inktank.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [bug report] crush: remove forcefeed functionality
Date: Fri, 6 Feb 2026 20:44:25 +0000 [thread overview]
Message-ID: <c0560b16985daf420d35bec6f4957414fff44bd2.camel@ibm.com> (raw)
In-Reply-To: <aYXu-_GsMPJpbv8m@stanley.mountain>
On Fri, 2026-02-06 at 16:39 +0300, Dan Carpenter wrote:
> [ Smatch checking is paused while we raise funding. #SadFace
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_all_aTaiGSbWZ9DJaGo7-40stanley.mountain_&d=DwIBAg&c=BSDicqBQBDjDI9RkVyTcHQ&r=q5bIm4AXMzc8NJu1_RGmnQ2fMWKq4Y4RAkElvUgSs00&m=EbbQA8mLawUrIpoBP1JgkEbj9ykB2zMAgU-BpxccK9crlqQp8eHphKm2eDfswppo&s=4dnJgIrt1z5jJRZwXTmcMBeS0RZ5lg-CZ04H1P9fcrE&e= -dan ]
>
> Hello Ceph Maintainers,
>
> Commit 41ebcc0907c5 ("crush: remove forcefeed functionality") from
> May 7, 2012 (linux-next), leads to the following Smatch static
> checker warning:
>
> net/ceph/crush/mapper.c:1015 crush_do_rule()
> warn: iterator 'j' not incremented
Yeah, it looks like an issue.
>
> net/ceph/crush/mapper.c
> 897 int crush_do_rule(const struct crush_map *map,
> 898 int ruleno, int x, int *result, int result_max,
> 899 const __u32 *weight, int weight_max,
> 900 void *cwin, const struct crush_choose_arg *choose_args)
> 901 {
> 902 int result_len;
> 903 struct crush_work *cw = cwin;
> 904 int *a = cwin + map->working_size;
> 905 int *b = a + result_max;
> 906 int *c = b + result_max;
> 907 int *w = a;
> 908 int *o = b;
> 909 int recurse_to_leaf;
> 910 int wsize = 0;
> 911 int osize;
> 912 const struct crush_rule *rule;
> 913 __u32 step;
> 914 int i, j;
> 915 int numrep;
> 916 int out_size;
> 917 /*
> 918 * the original choose_total_tries value was off by one (it
> 919 * counted "retries" and not "tries"). add one.
> 920 */
> 921 int choose_tries = map->choose_total_tries + 1;
> 922 int choose_leaf_tries = 0;
> 923 /*
> 924 * the local tries values were counted as "retries", though,
> 925 * and need no adjustment
> 926 */
> 927 int choose_local_retries = map->choose_local_tries;
> 928 int choose_local_fallback_retries = map->choose_local_fallback_tries;
> 929
> 930 int vary_r = map->chooseleaf_vary_r;
> 931 int stable = map->chooseleaf_stable;
> 932
> 933 if ((__u32)ruleno >= map->max_rules) {
> 934 dprintk(" bad ruleno %d\n", ruleno);
> 935 return 0;
> 936 }
> 937
> 938 rule = map->rules[ruleno];
> 939 result_len = 0;
> 940
> 941 for (step = 0; step < rule->len; step++) {
> 942 int firstn = 0;
> 943 const struct crush_rule_step *curstep = &rule->steps[step];
> 944
> 945 switch (curstep->op) {
> 946 case CRUSH_RULE_TAKE:
> 947 if ((curstep->arg1 >= 0 &&
> 948 curstep->arg1 < map->max_devices) ||
> 949 (-1-curstep->arg1 >= 0 &&
> 950 -1-curstep->arg1 < map->max_buckets &&
> 951 map->buckets[-1-curstep->arg1])) {
> 952 w[0] = curstep->arg1;
> 953 wsize = 1;
> 954 } else {
> 955 dprintk(" bad take value %d\n", curstep->arg1);
> 956 }
> 957 break;
> 958
> 959 case CRUSH_RULE_SET_CHOOSE_TRIES:
> 960 if (curstep->arg1 > 0)
> 961 choose_tries = curstep->arg1;
> 962 break;
> 963
> 964 case CRUSH_RULE_SET_CHOOSELEAF_TRIES:
> 965 if (curstep->arg1 > 0)
> 966 choose_leaf_tries = curstep->arg1;
> 967 break;
> 968
> 969 case CRUSH_RULE_SET_CHOOSE_LOCAL_TRIES:
> 970 if (curstep->arg1 >= 0)
> 971 choose_local_retries = curstep->arg1;
> 972 break;
> 973
> 974 case CRUSH_RULE_SET_CHOOSE_LOCAL_FALLBACK_TRIES:
> 975 if (curstep->arg1 >= 0)
> 976 choose_local_fallback_retries = curstep->arg1;
> 977 break;
> 978
> 979 case CRUSH_RULE_SET_CHOOSELEAF_VARY_R:
> 980 if (curstep->arg1 >= 0)
> 981 vary_r = curstep->arg1;
> 982 break;
> 983
> 984 case CRUSH_RULE_SET_CHOOSELEAF_STABLE:
> 985 if (curstep->arg1 >= 0)
> 986 stable = curstep->arg1;
> 987 break;
> 988
> 989 case CRUSH_RULE_CHOOSELEAF_FIRSTN:
> 990 case CRUSH_RULE_CHOOSE_FIRSTN:
> 991 firstn = 1;
> 992 fallthrough;
> 993 case CRUSH_RULE_CHOOSELEAF_INDEP:
> 994 case CRUSH_RULE_CHOOSE_INDEP:
> 995 if (wsize == 0)
> 996 break;
> 997
> 998 recurse_to_leaf =
> 999 curstep->op ==
> 1000 CRUSH_RULE_CHOOSELEAF_FIRSTN ||
> 1001 curstep->op ==
> 1002 CRUSH_RULE_CHOOSELEAF_INDEP;
> 1003
> 1004 /* reset output */
> 1005 osize = 0;
> 1006
> 1007 for (i = 0; i < wsize; i++) {
> 1008 int bno;
> 1009 numrep = curstep->arg1;
> 1010 if (numrep <= 0) {
> 1011 numrep += result_max;
> 1012 if (numrep <= 0)
> 1013 continue;
> 1014 }
> --> 1015 j = 0;
> ^^^^^
It looks like intentional initialization of variable. But let me spend some time
to better understand the crush_choose_firstn() and crush_choose_indep() logic
and the history of this function modifications in commits.
Thanks,
Slava.
>
> 1016 /* make sure bucket id is valid */
> 1017 bno = -1 - w[i];
> 1018 if (bno < 0 || bno >= map->max_buckets) {
> 1019 /* w[i] is probably CRUSH_ITEM_NONE */
> 1020 dprintk(" bad w[i] %d\n", w[i]);
> 1021 continue;
> 1022 }
> 1023 if (firstn) {
> 1024 int recurse_tries;
> 1025 if (choose_leaf_tries)
> 1026 recurse_tries =
> 1027 choose_leaf_tries;
> 1028 else if (map->chooseleaf_descend_once)
> 1029 recurse_tries = 1;
> 1030 else
> 1031 recurse_tries = choose_tries;
> 1032 osize += crush_choose_firstn(
> 1033 map,
> 1034 cw,
> 1035 map->buckets[bno],
> 1036 weight, weight_max,
> 1037 x, numrep,
> 1038 curstep->arg2,
> 1039 o+osize, j,
> 1040 result_max-osize,
> 1041 choose_tries,
> 1042 recurse_tries,
> 1043 choose_local_retries,
> 1044 choose_local_fallback_retries,
> 1045 recurse_to_leaf,
> 1046 vary_r,
> 1047 stable,
> 1048 c+osize,
> 1049 0,
> 1050 choose_args);
> 1051 } else {
> 1052 out_size = ((numrep < (result_max-osize)) ?
> 1053 numrep : (result_max-osize));
> 1054 crush_choose_indep(
> 1055 map,
> 1056 cw,
> 1057 map->buckets[bno],
> 1058 weight, weight_max,
> 1059 x, out_size, numrep,
> 1060 curstep->arg2,
> 1061 o+osize, j,
> 1062 choose_tries,
> 1063 choose_leaf_tries ?
> 1064 choose_leaf_tries : 1,
> 1065 recurse_to_leaf,
> 1066 c+osize,
> 1067 0,
> 1068 choose_args);
> 1069 osize += out_size;
> 1070 }
>
> There used to be a j++ around here but it was deleted.
>
> 1071 }
> 1072
> 1073 if (recurse_to_leaf)
> 1074 /* copy final _leaf_ values to output set */
> 1075 memcpy(o, c, osize*sizeof(*o));
> 1076
> 1077 /* swap o and w arrays */
> 1078 swap(o, w);
> 1079 wsize = osize;
> 1080 break;
> 1081
> 1082
> 1083 case CRUSH_RULE_EMIT:
> 1084 for (i = 0; i < wsize && result_len < result_max; i++) {
> 1085 result[result_len] = w[i];
> 1086 result_len++;
> 1087 }
> 1088 wsize = 0;
> 1089 break;
> 1090
> 1091 default:
> 1092 dprintk(" unknown op %d at step %d\n",
> 1093 curstep->op, step);
> 1094 break;
> 1095 }
> 1096 }
> 1097
> 1098 return result_len;
> 1099 }
>
> regards,
> dan carpenter
next prev parent reply other threads:[~2026-02-06 20:44 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-08 10:02 Support needed to continue Smatch work Dan Carpenter
2026-02-06 13:38 ` Dan Carpenter
2026-02-06 13:38 ` [bug report] net: ethtool: Introduce per-PHY DUMP operations Dan Carpenter
2026-02-06 17:04 ` Maxime Chevallier
2026-02-09 7:09 ` Dan Carpenter
2026-02-09 8:09 ` Maxime Chevallier
2026-02-09 13:10 ` Andrew Lunn
2026-02-10 10:37 ` Dan Carpenter
2026-02-06 13:38 ` [bug report] net: wwan: Add Qualcomm BAM-DMUX WWAN network driver Dan Carpenter
2026-02-06 15:12 ` Stephan Gerhold
2026-02-06 15:23 ` Dan Carpenter
2026-02-06 13:38 ` [bug report] iommu/amd: Introduce gDomID-to-hDomID Mapping and handle parent domain invalidation Dan Carpenter
2026-02-06 13:38 ` [bug report] drm/amdkfd: add debug set and clear address watch points operation Dan Carpenter
2026-02-06 13:38 ` [PATCH next] mtd: spi-nor: hisi-sfc: fix refcounting bug in hisi_spi_nor_register_all() Dan Carpenter
2026-02-06 14:14 ` Pratyush Yadav
2026-02-06 14:22 ` Miquel Raynal
2026-02-06 14:23 ` Miquel Raynal
2026-02-06 13:39 ` [bug report] media: synopsys: add driver for the designware mipi csi-2 receiver Dan Carpenter
2026-02-06 13:39 ` [bug report] crush: remove forcefeed functionality Dan Carpenter
2026-02-06 20:44 ` Viacheslav Dubeyko [this message]
2026-02-06 13:39 ` [bug report] net: ethernet: ti: am65-cpsw: enable bc/mc storm prevention support Dan Carpenter
2026-02-06 13:39 ` [bug report] phy: qcom: qmp-usbc: Add QCS615 USB/DP PHY config and DP mode support Dan Carpenter
2026-02-17 15:27 ` Konrad Dybcio
2026-02-27 5:11 ` Xiangxu Yin
2026-02-06 13:39 ` [bug report] drm/amd/display: add DC changes for DCN351 Dan Carpenter
2026-02-06 13:39 ` [bug report] media: rockchip: rkcif: add support for rk3568 vicap mipi capture Dan Carpenter
2026-02-16 13:33 ` Michael Riesch
2026-02-06 13:39 ` [bug report] drm/imagination: Add gpuid module parameter Dan Carpenter
2026-02-06 13:39 ` [bug report] ASoC: SOF: ipc4-control: Add support for generic bytes control Dan Carpenter
2026-02-06 13:39 ` [bug report] media: iris: gen1: Destroy internal buffers after FW releases Dan Carpenter
2026-02-06 13:39 ` [bug report] cifs: Fix locking usage for tcon fields Dan Carpenter
2026-02-06 13:40 ` [bug report] drm/xe: Avoid toggling schedule state to check LRC timestamp in TDR Dan Carpenter
2026-02-06 13:40 ` [bug report] iio: dac: adding support for Microchip MCP47FEB02 Dan Carpenter
2026-02-06 14:04 ` Andy Shevchenko
2026-02-06 14:33 ` Dan Carpenter
2026-02-06 15:14 ` Andy Shevchenko
2026-02-06 15:32 ` Dan Carpenter
2026-02-06 15:57 ` Andy Shevchenko
2026-02-10 10:26 ` Ariana.Lazar
2026-03-01 12:31 ` Jonathan Cameron
2026-03-02 10:28 ` Ariana.Lazar
2026-03-03 21:41 ` Jonathan Cameron
2026-02-06 13:40 ` [bug report] power: sequencing: qcom-wcn: add support for WCN39xx Dan Carpenter
2026-02-06 13:40 ` [bug report] io_uring: add task fork hook Dan Carpenter
2026-02-06 14:28 ` Jens Axboe
2026-02-06 13:40 ` [bug report] ACPI: battery: Adjust event notification routine Dan Carpenter
2026-02-06 21:28 ` [PATCH v1] ACPI: battery: Drop redundant check from acpi_battery_notify() Rafael J. Wysocki
2026-02-06 13:40 ` [bug report] iio: adc: Add support for ad4062 Dan Carpenter
2026-02-06 14:07 ` Andy Shevchenko
2026-03-01 12:34 ` Jonathan Cameron
2026-03-05 17:10 ` Jorge Marques
2026-02-06 13:40 ` [bug report] ext4: refactor zeroout path and handle all cases Dan Carpenter
2026-02-06 15:44 ` Ojaswin Mujoo
2026-02-06 13:40 ` [bug report] media: chips-media: wave5: Fix Null reference while testing fluster Dan Carpenter
2026-02-11 7:59 ` Nas Chung
2026-02-06 13:40 ` [bug report] phy: apple: Add Apple Type-C PHY Dan Carpenter
2026-02-06 21:47 ` Janne Grunau
2026-02-06 21:48 ` Sven Peter
2026-02-06 13:40 ` [bug report] spi: stm32: properly fail on dma_request_chan error Dan Carpenter
2026-02-06 13:40 ` [bug report] tracing: Properly process error handling in event_hist_trigger_parse() Dan Carpenter
2026-02-06 13:40 ` [bug report] drm/amd/display: Only poll analog connectors Dan Carpenter
2026-02-06 13:41 ` [bug report] fs/ntfs3: Add initialization of super block Dan Carpenter
2026-02-09 10:20 ` Konstantin Komarov
2026-02-09 15:35 ` [PATCH] (resend: correct threading) fs/ntfs3: avoid calling run_get_entry() when run == NULL in ntfs_read_run_nb_ra() Konstantin Komarov
2026-02-06 13:41 ` [bug report] remoteproc: imx_rproc: Introduce prepare ops for imx_rproc_dcfg Dan Carpenter
2026-02-06 16:29 ` Mathieu Poirier
2026-02-08 11:45 ` Peng Fan
2026-02-06 13:41 ` [bug report] irqchip/ls-extirq: Convert to a platform driver to make it work again Dan Carpenter
2026-02-06 13:41 ` [bug report] soc: rockchip: grf: Support multiple grf to be handled Dan Carpenter
2026-02-06 13:41 ` [bug report] drm/amdgpu: fix possible fence leaks from job structure Dan Carpenter
2026-02-06 13:41 ` [bug report] bio: add allocation cache abstraction Dan Carpenter
2026-02-06 13:41 ` [bug report] ASoC: codecs: ACF bin parsing and check library file for aw88395 Dan Carpenter
2026-02-06 13:41 ` [bug report] xfrm: always fail xfrm_dev_{state,policy}_flush_secctx_check() Dan Carpenter
2026-02-06 14:05 ` Tetsuo Handa
2026-02-09 9:43 ` [bug report] wifi: mwifiex: Allocate dev name earlier for interface workqueue name Dan Carpenter
2026-02-09 9:44 ` [bug report] apparmor: add support loading per permission tagging Dan Carpenter
2026-02-10 17:15 ` [apparmor][PATCH] apparmor: fix signedness bug in unpack_tags() Massimiliano Pellizzer
2026-02-09 9:45 ` [bug report] regulator: s2mps11: add S2MPG10 regulator Dan Carpenter
2026-02-09 14:07 ` André Draszik
2026-02-10 8:43 ` [bug report] btrfs: tests: zoned: add tests cases for zoned code Dan Carpenter
2026-02-10 19:05 ` David Sterba
2026-02-10 8:51 ` [bug report] ASoC: SOF: sof-audio: Add support for loopback capture Dan Carpenter
2026-02-13 5:56 ` [bug report] bpf: Fix a potential use-after-free of BTF object Dan Carpenter
2026-02-13 10:29 ` Anton Protopopov
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=c0560b16985daf420d35bec6f4957414fff44bd2.camel@ibm.com \
--to=slava.dubeyko@ibm.com \
--cc=amarkuze@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=idryomov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sage@inktank.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
all inboxes | Powered by JetHome®