Article View: linux.kernel.netdev
Article #13266Re: [PATCH net-next v3] net: preserve rps_default_mask on failed writes
From: Wang Zhan
Date: Mon, 09 Nov 2026 15:17
Date: Mon, 09 Nov 2026 15:17
96 lines
13751 bytes
13751 bytes
On Sun, 08 Nov 2026 13:19:12 +0000 Yingjie Wang wrote:
Two nits, if you happen to respin:
> @@ -105,34 +105,36 @@ static int rps_default_mask_sysctl(const struct ctl_table *table, int write,
> void *buffer, size_t *lenp, loff_t *ppos)
> {
> struct net *net = (struct net *)table->data;
> + struct cpumask *new_mask = NULL;
> struct cpumask *mask;
> int err = 0;
>
> - mutex_lock(&rps_default_mask_mutex);
> - mask = net->core.rps_default_mask;
> if (write) {
> - if (!mask) {
> - mask = kzalloc(cpumask_size(), GFP_KERNEL);
> - net->core.rps_default_mask = mask;
> - }
> - err = -ENOMEM;
> - if (!mask)
> - goto done;
> + new_mask = kzalloc(cpumask_size(), GFP_KERNEL);
> + if (!new_mask)
> + return -ENOMEM;
>
> - err = cpumask_parse(buffer, mask);
> + err = cpumask_parse(buffer, new_mask);
> if (err)
> - goto done;
> + goto out;
>
> - err = rps_cpumask_housekeeping(mask);
> + err = rps_cpumask_housekeeping(new_mask);
> if (err)
> - goto done;
> + goto out;
> + }
> +
> + mutex_lock(&rps_default_mask_mutex);
> + mask = net->core.rps_default_mask;
nit: use net->core.rps_default_mask directly in the read path and drop
the variable; there are no other users.
> @@ -105,34 +105,36 @@ static int rps_default_mask_sysctl(const struct ctl_table *table, int write,
> void *buffer, size_t *lenp, loff_t *ppos)
> {
> struct net *net = (struct net *)table->data;
> + struct cpumask *new_mask = NULL;
> struct cpumask *mask;
> int err = 0;
>
> - mutex_lock(&rps_default_mask_mutex);
> - mask = net->core.rps_default_mask;
> if (write) {
> - if (!mask) {
> - mask = kzalloc(cpumask_size(), GFP_KERNEL);
> - net->core.rps_default_mask = mask;
> - }
> - err = -ENOMEM;
> - if (!mask)
> - goto done;
> + new_mask = kzalloc(cpumask_size(), GFP_KERNEL);
> + if (!new_mask)
> + return -ENOMEM;
>
> - err = cpumask_parse(buffer, mask);
> + err = cpumask_parse(buffer, new_mask);
> if (err)
> - goto done;
> + goto out;
>
> - err = rps_cpumask_housekeeping(mask);
> + err = rps_cpumask_housekeeping(new_mask);
> if (err)
> - goto done;
> + goto out;
> + }
> +
> + mutex_lock(&rps_default_mask_mutex);
> + mask = net->core.rps_default_mask;
> + if (write) {
> + swap(net->core.rps_default_mask, new_mask);
> } else {
> err = dump_cpumask(buffer, lenp, ppos,
> mask ?: cpu_none_mask);
> }
>
> -done:
> mutex_unlock(&rps_default_mask_mutex);
nit: move this up to the closing brace and add a blank line before out:, so
the unlock is visibly paired with the lock.
Thanks
Technical Details
Message-ID:
<20261109151700.3979272-1-wang.zhan@smartx.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359388-linux-kernel-netdev=dewy.ruReferences:
<a235de028cc4160692127c6bf44ac567185b5449.1794143938.git.x-professor@outlook.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359388-linux-kernel-netdev=dewy.ru
From: wang.zhan@smartx.com (Wang Zhan)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v3] net: preserve rps_default_mask on failed writes
Date: Mon, 9 Nov 2026 23:17:00 +0800
Organization: Usenet Network
Message-ID: <20261109151700.3979272-1-wang.zhan@smartx.com>
References: <a235de028cc4160692127c6bf44ac567185b5449.1794143938.git.x-professor@outlook.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="386499"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:8Aj6fQwz2nQI8ZCRpFt8FdOoLCQ= sha256:y/sXe/sdhrTTJBUOBLCDfQZJpXJ0LYs0KOf8n9TXhnc=
sha1:y3jpIDhedTYWLZ0e8B9nycMyPYY= sha256:t7k/uE1LnjoOrzrAyPdtPSLQARB2BLnAr2puyj6cDYg=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id DDBED11384C; Mon, 9 Nov 2026 18:23:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.951
X-Spam-Status: No, score=-2.951 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=smartx-com.20260707.gappssmtp.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id ty9SHMi1SKd9;
Mon, 9 Nov 2026 18:23:08 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-359388-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=smartx.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id C4688113842; Mon, 9 Nov 2026 18:22:57 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id D8FECC7F52; Mon, 9 Nov 2026 15:17:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1794237453;
b=Z69B2cMuw7aesMX/QbSqGzrIDeOgOkozYi9anrptB/17JYtt9gg3vhjUKeVLb0K3epaD
VwHzazta2JnmtJQiHIg4us2ActOILUn9nKdXi967jExBrtb818vmbR4O0A8iy7PGcDiru
tEQmfBKnWHj9Nx9NM+SZ3NtAElzIM5fDgNVsyn/WLK7SzsYSdrfVmdjY1GOs+Kn+MUOTK
UbQGgBZgEZ0zJNpUSSMjvDUNbEOjQsgacGJlrIAWFG5mtmnEJBjoGHCJLQDBZj0B+Xk7j
3DeSaNoTE+rg0atYZmV/iYjWaQhIVhkQdENSCaWXDY72xtDqJ9Jjn1YD9ptP0LiqwnA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794237453;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=Xdh9DR4pvP3bPWHM/PE++xfHsGb4NZkwyA7cH/UYfZM=;
b=sNC+J9pJV9TPui7A9ENSJdCmHMikGiGRFe8vWMZ+7JR05ip5sqUb+MKkukUwz6Ds0aCs
wmNxwbz7FcZo1VrmXpv1nAR0NU9/ngeZCZqDn6jik2yB8LB2+KFCB+UQfnxZWGmdaUMAN
26jb7aCoC4N2MlzfcRrKn0SJR0uw7HFelgIX7OrKIssMRbr+4WLoj5UjZ560v1E4SNpWi
w0JZJba1WubsXf4oupVVFWi7cdPUF/1G900ery1QKW5fJLJ0r4E2Dawldk+35aUzkHygr
YT4UhnEdEnOs63f/lznWxWaPYEsb0uBQ+1OWpIi+Gk2eEDmrsByZ4E4OXY1sMWqQoYg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=smartx-com.20260707.gappssmtp.com header.i=@smartx-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=nnkIAT9j;
dmarc=pass header.from=smartx.com;
spf=pass smtp.mailfrom=smartx.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id AD998606A325;
Mon, 9 Nov 2026 15:17:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=smartx-com.20260707.gappssmtp.com header.i=@smartx-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=nnkIAT9j
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.50
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1794237447;
b=wV8PxAMXniuyOP1qIXrHtopblq0lYthnLiVwPPLyc2zOVw934U90n9rJ8g6Nnhfr+tmd
n/D/fhTfhIFWwFCMhDeXoRxC2CyrC1ngSF+OEbWWHm7HmMKG0azF/Uf3CF6bHsY9AU2iB
jae/VUiE4CC+SR4e7DsO5o4GKK8dHVii4CRDcTE0c6cCQZ+QMuDDcfhuf9lmCBO/t6PPf
Ey0OcXO2trqpLMZNh3KaUrfanqy8+SZDUexpOuFDtJiyhP1t3CiMl8zHvtgTg0BnC6w/b
dlOBgtjxSdH/joXzstAJkrtut3oglB1E+rD2ZUaa7hfBZ8wI3LhfyPUBhra+gn4j1vQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794237447;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=Xdh9DR4pvP3bPWHM/PE++xfHsGb4NZkwyA7cH/UYfZM=;
b=YJU9TMv9/kDgWjJhW/ouU0mfcmy7C5ScFIJoQeyI/RPszhtIJUx5bxa8HfnQPNTgI968
i90aAThfBjkCI8JwLhOGy4Eznxj4OYn8bdu2tUMavgCIWQKmqjG75Jys24PdcWu93EaH+
gxO4qRt9mjiZlN8BX8nayN+zlkSDat3ipoFeVu/ZBGPhi0X/iD2VSyikjkWDLFsw17im5
7JGrgagv7p7Yv2kJY2L2dTY0V5/2P61K5IAeYChy033jwqlZYdixhsV/zJTJ7z2HJtAxI
XjUiqZgJ9Fes4kdtYB6M2CdD5t2ITNGldVBxehcksoKeeH6WMwcx3h4cpDWUbxfhzzQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=smartx.com;
spf=pass smtp.mailfrom=smartx.com;
dkim=pass header.d=smartx-com.20260707.gappssmtp.com header.i=@smartx-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=nnkIAT9j;
arc=none smtp.remote-ip=74.125.82.50
X-Received: from mail-dl1-f50.google.com (mail-dl1-f50.google.com [74.125.82.50])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CC6F606A330
for <netdev@vger.kernel.org>; Mon, 9 Nov 2026 15:17:25 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0CC6F606A330
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=smartx.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=smartx.com
X-Received: by mail-dl1-f50.google.com with SMTP id a92af1059eb24-1aefd1bf74aso837705c88.1
for <netdev@vger.kernel.org>; Mon, 09 Nov 2026 07:17:25 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=smartx-com.20260707.gappssmtp.com; s=20260707; t=1794237445; x=1794842245; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=Xdh9DR4pvP3bPWHM/PE++xfHsGb4NZkwyA7cH/UYfZM=;
b=nnkIAT9j6W5kjL2AukY6s9LACsUL/7/5/3oeWkfyGSy9CDbNWy7IJd/+qGnPI/Rvrs
h8vprcezd8yI62kK0DZeROYl07EOnZQ7yPXw0f+CA9vbvyNqAqKFVhAgS59o2nVboAkK
u/5VSHDv0mrWUEOv5AH8tFKnEmbw295JSMmHYA5dPR4YZJ7VDcfaMOOoZDQuvePTlnXo
ra3a83LDvmY3qZT2nsnq7zgEm2qGS8ucdse3VXhSCb2kK//HknKd8m8gUmXB/VqYWGIF
qk4xqOfqBOrhKKShpRCDXqVJJ1aTtYCR3FBuSuceszHHeKLBdgIKr8c0rb/PjzxS/YOc
nrIg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794237445; x=1794842245;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=Xdh9DR4pvP3bPWHM/PE++xfHsGb4NZkwyA7cH/UYfZM=;
b=1pjro736RWNz0FSYZ+X5DfHyVv/VVaTtrPvlfKkVZ31yMzwV47onl9tl9Rq+NcUhqt
zAWDsErwHpxRAMfhi87frTPvl7YcW+BO2sQECftc30lnpz0M4zS6HeBphyWgPcrOS6TU
B6w8KgXHKbkvzsDbieDbhP9xqqZ3mbS0tfDCau9N7fENd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d with SMTP id a92af1059eb24-1b39fe2fcd9mr6125970c88.3.1794237444186;
Mon, 09 Nov 2026 07:17:24 -0800 (PST)
X-Received: from localhost.localdomain ([174.136.204.24])
by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b3731487edsm15203046c88.2.2026.11.09.07.17.17
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Mon, 09 Nov 2026 07:17:23 -0800 (PST)
X-Cc: Wang Zhan <wang.zhan@smartx.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@kernel.org" <edumazet@kernel.org>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"horms@kernel.org" <horms@kernel.org>,
"kuniyu@google.com" <kuniyu@google.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
X-Mailer: git-send-email 2.47.3
X-In-Reply-To: <a235de028cc4160692127c6bf44ac567185b5449.1794143938.git.x-professor@outlook.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list