From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f202.google.com (mail-qt1-f202.google.com [209.85.160.202]) (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 C668A3C8700 for ; Wed, 8 Apr 2026 12:56:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775652996; cv=none; b=IG+QYdPm/bBaRI5awxi5aSfPuhEHtwL1Jz5ne5aMa0PbD3ZMS+KETxo9DLOq3WkQ0wzw4+BhAuylWY1kJ6nJdTUrlB9O3rB5cFHxA4aqcRyeQi+0BtnD1d4qfc+DWEgPoaHyA4i7UqrzYd8RXtzLjbaewp32fqfE8tnSJsxZ/XQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775652996; c=relaxed/simple; bh=T9tmsoNDi9EwJ9IudjdOmWW1iLs+gy8wbVDhf+VDlTA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hPjTV91MLM4NrhSq2V08uRtN8/12YxYptVuv+s5Kk/k+UlNBIvk4xbrLqZ6KDljR3O88Pt8bOzUQg9gCYos8rSprlqqJcP39ZkTbRfVuRj3PZEbAqEdvkcz+OuOWPH1rwYXrmGmXjFE/Eilo4pBJlkphZgUlCQGhpp0O3Upes6M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=dYBiyWJq; arc=none smtp.client-ip=209.85.160.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dYBiyWJq" Received: by mail-qt1-f202.google.com with SMTP id d75a77b69052e-50da529ff48so46890691cf.3 for ; Wed, 08 Apr 2026 05:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775652994; x=1776257794; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=SYfIeb29DIYWv7AbwoDoluUX/yJHqHXJP8AnpkO+hKw=; b=dYBiyWJq4+t8mVIep4I3fx0p8WHbaBgSF9ageLjJWUOGulcnqWniJiL4x1XasKfkN5 75vlutAQPSrcTSM5ZcQuq/Hr0rPebWBcTY12Rfw4f42askLcYKBR9lwDjCEU1bMWBYrP /XQC4iHgCuMvjNuj0HJXBogTW/QCRYG3v8IuMx2ZG3zA9hOPmx9H3fxGZqyBzu/7Kmtn vd6ifZyZxFYWFruvj29Njy9xEN8WFvATF1GGK/OboZqD4zoeeIzm6Tz6lwldHehiXqNF 6SGiOJIelFbqoqwPJEWqeO6pQWDwEZzSxMVAvhJS9bU7VrX3wwd52k5LWF6wUhfxQl8I pv/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775652994; x=1776257794; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SYfIeb29DIYWv7AbwoDoluUX/yJHqHXJP8AnpkO+hKw=; b=GTwtszaQIr59gxVqIzKWCL2jasPOPnNUofpET6UzxEy4MjiSaiCqIJmIa3mG876LGI Jzhk8F6eXKizOVYQfXZ6Y1o596hdsQzmrOwHIYWjQ7HsjALDP770VONOUzfrjvYs/ayA RiDsgPzkNrKU2s+7HyPXAJcYHExz9pnw8RZIukjzxu3oXj0OBTuOmzaXLoVHJXGuhPdM a1W4pJ9ksN0tHu3WauR2NKSYE1KpOvWhI2FQce4Q46C5045Js9JoBKKlM1j2tEr+MeLE MWiKBjhBsDt8h/rMD+q6gbpK185Iy+2leHLVdNJwxUc5NXNWfkXsQ9sozFgBWqLol7Az x9Vw== X-Forwarded-Encrypted: i=1; AJvYcCVNo42T7SP5mF+mHe5HcVEbKCnbaxv/OF5FbWI3dnfbLTPNS/mGAjqOl03D/YAx1+/6lfjyVZ4=@vger.kernel.org X-Gm-Message-State: AOJu0YxhdJeeAoTsKQGHeEZgm8NA0Yr2EzqlWAlrkUDebhYqhEam6ynl ZJTiDvG8hELiEbYF43fmRq+S9SfxajsX6VMzIydkCbTpwrEdDgSzvdjhi2ei0kN40pndxzDCXVA toeTjQmPEwqXiEA== X-Received: from qtwv14.prod.google.com ([2002:a05:622a:14e:b0:50d:9e35:765b]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:ac8:5703:0:b0:50d:743e:439e with SMTP id d75a77b69052e-50d743e51e7mr235656131cf.3.1775652993410; Wed, 08 Apr 2026 05:56:33 -0700 (PDT) Date: Wed, 8 Apr 2026 12:56:07 +0000 In-Reply-To: <20260408125611.3592751-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260408125611.3592751-1-edumazet@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260408125611.3592751-12-edumazet@google.com> Subject: [PATCH net-next 11/15] net_sched: sch_hhf: annotate data-races in hhf_dump_stats() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Jamal Hadi Salim , Jiri Pirko , Kuniyuki Iwashima , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Content-Type: text/plain; charset="UTF-8" hhf_dump_stats() only runs with RTNL held, reading fields that can be changed in qdisc fast path. Add READ_ONCE()/WRITE_ONCE() annotations. Fixes: edb09eb17ed8 ("net: sched: do not acquire qdisc spinlock in qdisc/class stats dump") Signed-off-by: Eric Dumazet --- net/sched/sch_hhf.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/net/sched/sch_hhf.c b/net/sched/sch_hhf.c index 69b6f0a5471cb9a3b7b760144683f2b249091d89..1e25b75daae2e5de31bd212dfa1f6d7aea927174 100644 --- a/net/sched/sch_hhf.c +++ b/net/sched/sch_hhf.c @@ -198,7 +198,8 @@ static struct hh_flow_state *seek_list(const u32 hash, return NULL; list_del(&flow->flowchain); kfree(flow); - q->hh_flows_current_cnt--; + WRITE_ONCE(q->hh_flows_current_cnt, + q->hh_flows_current_cnt - 1); } else if (flow->hash_id == hash) { return flow; } @@ -226,7 +227,7 @@ static struct hh_flow_state *alloc_new_hh(struct list_head *head, } if (q->hh_flows_current_cnt >= q->hh_flows_limit) { - q->hh_flows_overlimit++; + WRITE_ONCE(q->hh_flows_overlimit, q->hh_flows_overlimit + 1); return NULL; } /* Create new entry. */ @@ -234,7 +235,7 @@ static struct hh_flow_state *alloc_new_hh(struct list_head *head, if (!flow) return NULL; - q->hh_flows_current_cnt++; + WRITE_ONCE(q->hh_flows_current_cnt, q->hh_flows_current_cnt + 1); INIT_LIST_HEAD(&flow->flowchain); list_add_tail(&flow->flowchain, head); @@ -309,7 +310,7 @@ static enum wdrr_bucket_idx hhf_classify(struct sk_buff *skb, struct Qdisc *sch) return WDRR_BUCKET_FOR_NON_HH; flow->hash_id = hash; flow->hit_timestamp = now; - q->hh_flows_total_cnt++; + WRITE_ONCE(q->hh_flows_total_cnt, q->hh_flows_total_cnt + 1); /* By returning without updating counters in q->hhf_arrays, * we implicitly implement "shielding" (see Optimization O1). @@ -404,7 +405,7 @@ static int hhf_enqueue(struct sk_buff *skb, struct Qdisc *sch, return NET_XMIT_SUCCESS; prev_backlog = sch->qstats.backlog; - q->drop_overlimit++; + WRITE_ONCE(q->drop_overlimit, q->drop_overlimit + 1); /* Return Congestion Notification only if we dropped a packet from this * bucket. */ @@ -687,10 +688,10 @@ static int hhf_dump_stats(struct Qdisc *sch, struct gnet_dump *d) { struct hhf_sched_data *q = qdisc_priv(sch); struct tc_hhf_xstats st = { - .drop_overlimit = q->drop_overlimit, - .hh_overlimit = q->hh_flows_overlimit, - .hh_tot_count = q->hh_flows_total_cnt, - .hh_cur_count = q->hh_flows_current_cnt, + .drop_overlimit = READ_ONCE(q->drop_overlimit), + .hh_overlimit = READ_ONCE(q->hh_flows_overlimit), + .hh_tot_count = READ_ONCE(q->hh_flows_total_cnt), + .hh_cur_count = READ_ONCE(q->hh_flows_current_cnt), }; return gnet_stats_copy_app(d, &st, sizeof(st)); -- 2.53.0.1213.gd9a14994de-goog