From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f45.google.com (mail-yx1-f45.google.com [74.125.224.45]) (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 7307D313E3F for ; Wed, 6 May 2026 19:31:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778095912; cv=none; b=UgkO0x68Fb6mj+lqFyza9K8bIgbb68lCO+qzPPDQV1AaUUWToiAzgPI6U2hVi+LirQox+q4gL/5c9G7fs3/l2PoCacrTDvIxlJW8KTRjq+XzGhvhjK2fMD6DQL2/brb6+hn986P9uA9civVHPBpZwevMHm8e07kkZYVY6xWcBIo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778095912; c=relaxed/simple; bh=iZSa9x+NGfYe7SE7VaqLueKdW2vGNSge+YaCCBwijLA=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: Mime-Version:Content-Type; b=XryeRb9Hb8jZzp/krKj5qSK9DoO7WOEFZmoZFHnbWG1lsnrLvRN3n1umjb1ARxcB3ods1l9FxNaOTS1hxy853uMhBKWautVDKj4RzFIg7ETwfEpa0VeGk4/IVwA5rtjun733w3BLFaz23oNZAZKtbz6tR6Lt5RYPCnVxqIFffII= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Rvd+kKoJ; arc=none smtp.client-ip=74.125.224.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rvd+kKoJ" Received: by mail-yx1-f45.google.com with SMTP id 956f58d0204a3-65c37eafcbeso9545d50.1 for ; Wed, 06 May 2026 12:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778095910; x=1778700710; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=x8BkpSYgNobLaOaccEcCmnUd9ThyuPsAjj7zXcBaElY=; b=Rvd+kKoJdTQ4aR/2xY+py7GZxaMbX/XPcT8pMnU32n7xeqKD2R2fX/rpTViSiwjFQA btDmcTQ+ZeP74PhNeErtuH30JgQmYPhuH96dYb0BhRVs+xrkxH2Ybi8qxLeQo2Pq+CX8 aolZ+CH2zWFEIUJXY+d/l1gANVoews6JuzylEBl43wWQnkquF+FAYhBhYl9ZyO2qH075 ePsjh0KvVBxdv80g18fe2KocpivbFTtrM6FlTdJ6GaK7vQhmduscUvmTTc9WQW2uJacw DdOHkXb74AQYcnkW7a8UMDdLhnEXth14GnUZWIdX1l+oBnVjpNKW/+KiDlUKQlnWqYiP TMwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778095910; x=1778700710; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=x8BkpSYgNobLaOaccEcCmnUd9ThyuPsAjj7zXcBaElY=; b=n2cbKLt4faOdQTIDlHGzwbc8eUWD97MpM2tQEBBYqYfIF+VSdU44nxKjLK0/2zsQYT MnDm69Vm02FqeI0kUy6dRZa2dtiQ6tg+xb6B7oFxK9JMSD55dhTRMj9wNaRtPegHbOl+ MifC4w2Cpj01ao/rIXWC7YOS3QkKL5bHe+OHDJtqwfoJaqe0CHXweZUJqEkWvEz0d0dS WyrMeI7PTCpzO8R/guvb/watKzsinrBJ4+AWLd0RbIKLg6LliRg8poaRbBA/ANVJzzjA GaD4XotRnX6GoP2c9LYuN7sf9npengmZW4tNWB+ycB/MtZEpPVumge9Cs9rkOLplNLL0 joTA== X-Forwarded-Encrypted: i=1; AFNElJ/gYA5GuBboEyBsDqThFiGNMetwUu0aLRN/TKpClCRJYkoL6soY8T3K6f16oFS/TUozhueOALxTxa3+dec=@vger.kernel.org X-Gm-Message-State: AOJu0YxN4sjIfzydKaG5rcN3EZ/+4iNYRc+N9kAAVj29NCAX4iiDuySM rN76PHn6UxfZtcl6imHz3xdi08KAKTZKxc017KGhXP2WNsVrxqw/i5+w X-Gm-Gg: AeBDies7I9nzFdpoSt+HjyJrBePFLbgUodFqlXqrwyIxYx/IXZEwDUGt389vQgbFC7c A/f9JiBfknQXZhDTEc6JI5Xqx9r8yJqRZLmtPWx+ltm+xuwUPJoZVBEIU/ecnd4yaWJhAbC7ZK8 B36qdMJ2NRPzt8Asi8eKXSGQ2D3xHL3Nh9T9kW9eGOzlH100wy2nMYszbyt6/FODO8a7EKrojv/ /FxmWIrIkbaiFmYrrB6utTu0FZaSjqGj31LffbtXunNUu3+lPbRMX/ETM3qqFgIknHrnPz3zXBA BR1zNn9Q6Q3gzDhitb3EbiptdNQMaQ6yauQTfPa98EQakaGIdtVlL2bGG4ORmZ386c3ad228WGr sAN/nwBilf7PMsJoGO7siLMBOB1XZfsRd2pWlAE7PHS/ggdYWx5FicW5zsNplm1elAZTlviVa1i HZ0v94lB9sn8yi1nWLsAfb9SNE0CQjDwCz+Vv1EEU3EbsZREf5oMyN5i9IMIUYqvw8xgpTPxP67 uRQoW2FQK66RmI= X-Received: by 2002:a53:cf0a:0:b0:651:97ba:8507 with SMTP id 956f58d0204a3-65c79a2e692mr3769937d50.59.1778095910361; Wed, 06 May 2026 12:31:50 -0700 (PDT) Received: from gmail.com (172.235.85.34.bc.googleusercontent.com. [34.85.235.172]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-65c7af99a95sm1524615d50.12.2026.05.06.12.31.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2026 12:31:49 -0700 (PDT) Date: Wed, 06 May 2026 15:31:49 -0400 From: Willem de Bruijn To: Daniel Zahka , Jakub Kicinski , Andrew Lunn , "David S. Miller" , Eric Dumazet , Paolo Abeni , Willem de Bruijn , Willem de Bruijn Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: <20260505-psd-rcu-v1-2-a8f69ec1ab96@gmail.com> References: <20260505-psd-rcu-v1-0-a8f69ec1ab96@gmail.com> <20260505-psd-rcu-v1-2-a8f69ec1ab96@gmail.com> Subject: Re: [PATCH net 2/3] netdevsim: psp: serialize calls to nsim_psp_uninit() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Daniel Zahka wrote: > The debugfs write handler, nsim_psp_rereg_write(), can race against > nsim_destroy() and against itself, causing nsim_psp_uninit() to run > more than once concurrently. Two complementary changes serialize all > callers: nit: sounds and looks as if this would be simpler as two patches. but no need to respin just for that. > > 1. Delete the psp_rereg debugfs file from nsim_psp_uninit() before > doing the actual teardown. debugfs_remove() drains any in-flight > writers and prevents new ones from starting. > > 2. Add a mutex around the body of nsim_psp_rereg_write() so that two > concurrent userspace writers cannot both enter the teardown path > at once. > > The teardown work itself is moved into a new __nsim_psp_uninit() that > the rereg handler calls under the mutex, while the public > nsim_psp_uninit() wraps it with the debugfs_remove()/mutex_destroy() > pair so nsim_destroy() doesn't have to know about the psp internals. > > Fixes: f857478d6206 ("netdevsim: a basic test PSP implementation") > Assisted-by: Claude:claude-opus-4.6 > Signed-off-by: Daniel Zahka Reviewed-by: Willem de Bruijn