From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.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 72F07388873 for ; Tue, 23 Jun 2026 17:31:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782235862; cv=none; b=Q2xlyy2u5L1b3VHhftcpv0feFmHuP4rtT/iyDEwjPJyfLPIZ+9DvQLQ8xW8oozGzt4L8zJHTsnsAHA+ATK4EVPsQdK8xjcQ6w0O7Mg+dvo+bP+o/N3JQczNUM5SmgysZ+zn2+Kk083FTkDkrl7oxQlsLrZ5dQVVFm0R9vjJdCdE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782235862; c=relaxed/simple; bh=5GPCDXgh/aNXyLYA8BwFvMmL4iU4HtRYnFjYr3LKCFI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=X3Cpc7fwfQqg3o6pS11O2D/hjHA6hfHu8MDKc3qdN9BMJ4hl3UhuOUwHk4hIcGoUK7h2Q3qeDONkt2akpDm2bE/WMyc4bPINY/1Ts/T1UnJHFHAUaY+k49hTkYbC2tIfqRgteKjEaLQpH/+f0rEyvfXykBoZyCuab+luNz2JSe4= 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=GlsFlyeB; arc=none smtp.client-ip=209.85.222.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="GlsFlyeB" Received: by mail-qk1-f202.google.com with SMTP id af79cd13be357-91931144870so5571885a.1 for ; Tue, 23 Jun 2026 10:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782235860; x=1782840660; 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=WiarDXF7RoDxoYlqhiKZBD/2JS5v/w8baNECo+JUhmQ=; b=GlsFlyeBYxX8RoWbMYely6kmJ+Y55hMLdXLCSqDCvaT7zwGGhc4CojaCR34cY1l1DA tcJ+41wGmIXedE+PH9vnvBF/4J5F+dPbENotPyZB6XvJAXN4NBap1lQFsgmEoN1g2qF0 kwdlP1jfw0055yLwa9gOS6aawr+VR2iGm6CO4nXqcWXIoXu40cbyqyInZ3lWEZhjzMp7 5IoZJD8fhOaG6/4F9ZfVKg2nAgjOtC/rlKL/7JJyGbU+CPHEMCn3Zp3+iihYQ5FVtCUg jHAOQ7YCmNJOz7w6kEROafaT5CeUfP3QKwk5Pq4py1Z+HTC8oWa0aENobSZUt/YTghC6 XcLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782235860; x=1782840660; 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=WiarDXF7RoDxoYlqhiKZBD/2JS5v/w8baNECo+JUhmQ=; b=fTHNsTeLichpare1R72km+w2bjEKM+YzFFpi1Eb2wB77Xts/SeJP1JpRHbbO21K/mY jSIT0fn1keAHqf4Uq4uY9HkRWJrjY3rgo7oPsXupRI2nPkGzwbPMqQ0lPs38fBy2CKdC fqjfvumK/5xmqwCz3Cc99haRElA9ztfRuerXkb0tsESTB5dls4IYaV+WuTS8vdP6vleo w8sjZeIsXe0j4qTz4P+91PD1FoMSLRE3RqSspC60ICl+DixVVzelHIDJOc2t3gZGz/xt kakpXn7BVY6tDRPDnATJfcy87Rfof57EeWsi0OloYeeMUHFgkO8hItH0+BHYytD4jZ1i 8FqQ== X-Forwarded-Encrypted: i=1; AFNElJ+ztPf5orDs1r9XDTKV5pEx3s4kmQXXa7J7kDtz/Tb9g8wn+PrErnrbY1NI1SCl8gYBXyRckgA=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/hVRXkNUgh2H2ByBo2uAJ/8agDlHYtRx3NQuzJ/yK5f8xmhnF i26pN6tNyXltwGDHVTT1F3Kvt0FQAXBFeIWG2zaouxJcaSqbJovNmvMu+DXo1vIUTiPyeSrpmPF Op4TrwB5vkXNQuQ== X-Received: from qklo26.prod.google.com ([2002:a05:620a:d5a:b0:915:67bb:b14b]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:620a:4092:b0:915:9047:940b with SMTP id af79cd13be357-9264433523emr639605985a.1.1782235835968; Tue, 23 Jun 2026 10:30:35 -0700 (PDT) Date: Tue, 23 Jun 2026 17:30:30 +0000 In-Reply-To: <20260623173030.2925059-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260623173030.2925059-1-edumazet@google.com> X-Mailer: git-send-email 2.55.0.rc0.799.gd6f94ed593-goog Message-ID: <20260623173030.2925059-3-edumazet@google.com> Subject: [PATCH v2 net 2/2] tipc: avoid busy looping in tipc_exit_net() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Kuniyuki Iwashima , Xin Long , Jon Maloy , tipc-discussion@lists.sourceforge.net, netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Content-Type: text/plain; charset="UTF-8" Blamed commit introduced a busy-wait loop in tipc_exit_net() to wait for pending UDP bearer cleanup works to complete: while (atomic_read(&tn->wq_count)) cond_resched(); This loop can busy-wait for a long time if cond_resched() is a NOP. This typically happens if the netns exit is executed by a high priority task, or under kernels configured without preemption (CONFIG_PREEMPT_NONE). In such cases, it wastes CPU cycles and can lead to soft lockups. Fix this by replacing the busy loop with wait_var_event(), allowing the thread to sleep properly until the work queue count reaches zero. Accordingly, update cleanup_bearer() to use atomic_dec_and_test() and wake_up_var() to wake up the waiter when the count drops to zero. This uses the global wait queue hash table, avoiding the need to bloat struct tipc_net with a wait_queue_head_t. The atomic_dec_and_test() provides the necessary memory barrier to ensure the wakeup is not missed. Fixes: 04c26faa51d1 ("tipc: wait and exit until all work queues are done") Signed-off-by: Eric Dumazet Cc: Xin Long Cc: Jon Maloy Cc: tipc-discussion@lists.sourceforge.net --- net/tipc/core.c | 4 ++-- net/tipc/udp_media.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/net/tipc/core.c b/net/tipc/core.c index 1ddecea1df6e9100334c47a28ff6c065292fb9ad..315975c3be8186784e9c44c9ff69d62c17ffd4b9 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c @@ -45,6 +45,7 @@ #include "crypto.h" #include +#include /* configurable TIPC parameters */ unsigned int tipc_net_id __read_mostly; @@ -118,8 +119,7 @@ static void __net_exit tipc_exit_net(struct net *net) #ifdef CONFIG_TIPC_CRYPTO tipc_crypto_stop(&tipc_net(net)->crypto_tx); #endif - while (atomic_read(&tn->wq_count)) - cond_resched(); + wait_var_event(&tn->wq_count, atomic_read(&tn->wq_count) == 0); } static void __net_exit tipc_pernet_pre_exit(struct net *net) diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index 66f3cb87a0aaaac8f40e8f237ab9a44d539b1cd8..62ae7f5b58409c89798c915dee752ac42487581f 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -830,7 +831,8 @@ static void cleanup_bearer(struct work_struct *work) synchronize_net(); dst_cache_destroy(&ub->rcast.dst_cache); - atomic_dec(&tn->wq_count); + if (atomic_dec_and_test(&tn->wq_count)) + wake_up_var(&tn->wq_count); kfree(ub); } -- 2.55.0.rc0.799.gd6f94ed593-goog