From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (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 626D445039 for ; Wed, 27 May 2026 20:06:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779912403; cv=none; b=aCH4nTC8b54puYzdDXxnY+LR1z8fTzK+fK8bxg69XNkpTm+XT1yWU6v3izduOYyYvRke5rioXAmCaSv6LGH8epWJ+W5DqESxtMHlfQ2EcDMQ8Zh6cpXwME3xoEDflCH0bRpOyOGYLrSQDa0n5R2T9BwnBJI1jMrLrF9Z/Vndgls= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779912403; c=relaxed/simple; bh=5YVfbsjw+y1IlJF2f6ulbFhIo+daSv19fVrTFMovuOw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LdOuJPpyZt0Op467UbLxlO2YOh9g/IV0T8tOXown2aEHZOX/QcZ27ij7osVEXJXQouYhUO1YNet6M1lGS8pTNuRQEJCMok4GldR2QK0utw8tNSAP75/u+e1DcduJp+YdvRPZWV+2PhXQ/q2lTmK6jqo7kXLDq0/Du95o+TFsiYY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b=HXpLKu/w; arc=none smtp.client-ip=209.85.222.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="HXpLKu/w" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-90fa736d46fso721657085a.0 for ; Wed, 27 May 2026 13:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1779912401; x=1780517201; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=nJr2tB77juL4ByDP6LkH0aebWzIYmr6O5s8SXDRsvVw=; b=HXpLKu/w4cWeL5H3itsA2pQGUP8s8V1cS3/TgPtYLYRHJc6FnlWm1EBDb5eP2kh8jH PdHJoNtktHAXcsugyugfePWgJy1G4MojbM5m593XaqrJQwE1vyowuVoEOi0KuLrk/mCH Ym7snEHpLWMnTYdvRHb1HO8RYsH4zj7/p6UZp10xB8YgrvRJfMaS+bArlatfak8BhAvU Bth1lcAGxyX5UF007gOZvp00F/17Hofo5NU/cyU98iV6KqrJ7CZ1+qOsfbCX3CqMSjC2 HvdL6Z+6gOybGnbjAwHhGdF/7sBwckyFP2eqNlqQPI9Yk6r3hmUV4EgvUyzMn15FqvV4 SDHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779912401; x=1780517201; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nJr2tB77juL4ByDP6LkH0aebWzIYmr6O5s8SXDRsvVw=; b=LujuEruVpH5sQiJyO83xFwfnje4mbUw+KS2oiWEcimFOTv6Z0iqab5X5TlV1zPmeeo 4YLLZKTff6iMGk+IFaklSG2KKWMOroNiNPzhkelRyEq8I9zWQbt3e2Qfhmh6EAQqHXVY JIu26EZ2q5r4czTtXKgBOdFis0iRba7CD0294BEC5VtPm5Qy21lARrRlgFw5ohHtTRBP V2mF5Jp4+rgaV8Sd66peXb8eux88S79qLERcWVjbYCaZqY9QaeFaFrUaNa0XUBlbyuyu C+3/1cWz+eXi4K1ai6C9CuuPyXVb67+zwWVuNozY7KpoanWAtJUm67fpWvmTKEVRfi81 Wcbw== X-Forwarded-Encrypted: i=1; AFNElJ/ugsyQQIluwH3YqEkTQqgKl52jliZoiyDAuNhREcuCeJlA0BpV6446bj2F2CkdB4NOoCDxTbqTjhsjnLQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2Ny4/tB6936BTvTF1CGY9xuxlwn7vtiNKAIY6M6viX8kmtzZi 4fTLcwqgSN21Xx1LPFSdRLU3ZUDHROaQrbOihDrD0B99S6eF40be1CqGw09WC6pT2ig= X-Gm-Gg: Acq92OH4iIe/Etpsn8IqsdAUP57VMrnMCTS0eiQkpCEkA7yw1xrQr1tPK/LJsoOGMAI 2IKEBNuuSD57Za3QGT0RgRPRzxyUk04hfg9wmuuYnf1urJLG4tXhmFM9Pg+TkoDsVrzsyIjlfI5 bzwF37uYG51hYR+qAXPDRyOO//fMNuJ3x5Zx0L/NCrL7Mb6dPMzl93nlmk+Er+i3x+smSE/vfjw YWhBjIZc6OugqmAzOfVCg2D0/q1k7GhmeYjDpsWT02OQWMqirPuVKmGF7aojLQyUii5qMf8Gl57 J9lNfuC3k83tbvPm7gMY/bv0urmmEQt94Hz7UUG9pkCcSF+u1P5QZv6xz3l6wJxQY3J3a985Mhd sogoNYwGxnTneQz0uG2n4qKgpxaJiXpa70as83jDu3MYN7Ly63xAXXXeS8mwTGhmJ/doOQGfNZa bXevLzwyj4PGQS8XemGp0UKLJ/HmE3HKFhg3e7XapplMpCHzdn8MPe/qHKoCXjnA== X-Received: by 2002:a05:620a:408e:b0:8f8:d217:f46a with SMTP id af79cd13be357-914b48e0887mr3337181485a.8.1779912401292; Wed, 27 May 2026 13:06:41 -0700 (PDT) Received: from plex ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-914f863287dsm570050085a.0.2026.05.27.13.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2026 13:06:40 -0700 (PDT) Date: Wed, 27 May 2026 20:06:39 +0000 From: Pasha Tatashin To: Pratyush Yadav Cc: Pasha Tatashin , rppt@kernel.org, sourabhjain@linux.ibm.com, jbouron@amazon.com, akpm@linux-foundation.org, bhe@redhat.com, linux-kernel@vger.kernel.org, dan.carpenter@linaro.org, rafael.j.wysocki@intel.com, piliu@redhat.com, kexec@lists.infradead.org, skhawaja@google.com, graf@amazon.com, mario.limonciello@amd.com Subject: Re: [PATCH v5 3/5] liveupdate: block session mutations during reboot Message-ID: References: <20260518125459.1092373-1-pasha.tatashin@soleen.com> <20260518125459.1092373-4-pasha.tatashin@soleen.com> <2vxzo6ic8ysn.fsf@kernel.org> <2vxz4ijz8v48.fsf@kernel.org> 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2vxz4ijz8v48.fsf@kernel.org> On 05-22 14:52, Pratyush Yadav wrote: > On Mon, May 18 2026, Pasha Tatashin wrote: > > > On 05-18 18:31, Pratyush Yadav wrote: > >> On Mon, May 18 2026, Pasha Tatashin wrote: > >> > >> > During the reboot() syscall, user processes may still be running > >> > concurrently and attempting to mutate sessions (e.g., creating, > >> > retrieving, or releasing sessions). To prevent this, introduce > >> > luo_session_serialize_rwsem to synchronize mutations with the > >> > serialization process. > >> > > >> > All session mutation operations (create, retrieve, release, ioctl) take > >> > the read lock. The serialization process (luo_session_serialize) takes > >> > the write lock and holds it indefinitely on success. This effectively > >> > freezes the LUO session subsystem during the transition to the new > >> > kernel. If serialization fails, the lock is released to allow recovery. > >> > >> Good idea I think. > > > > Hi Pratyush, > > > >> > >> But, do we need a new mutex? Can't we use luo_session_header->rwsem? > >> Session creation and release take the header rwsem at one point anyway, > >> so perhaps we can just reuse that? > > > > The sh->rwsem is for protecting the the session list. We only take it as > > a writer when modifying the list (insert/remove) and as a reader when > > traversing it. Also, we drop sh->rwsem as soon as we've acquired the > > per-session mutex to allow other list operations to proceed while a > > session is being modified. > > > > Because of this, many session mutation operations (specifically ioctl > > calls) don't touch sh->rwsem at all—they jump straight to the session > > state via the file's private_data. To use sh->rwsem to block > > these mutations, we would be forced to add down_read(&sh->rwsem) to > > every ioctl path. This would be a layering violation, coupling list > > management to per-session data mutations, and would introduce a global > > bottleneck for operations that are otherwise independent. > > As for the layering violation, I think we would need to change the > semantics of the lock -- it no longer protects only the list, but other > session operations as well. > > But yeah, if we do this then operations like session creation would have > to wait for ongoing session operations like PRESERVE_FD. My argument was > based around the fact that session creation or removal should not be > very frequent (and don't happen in the hot path anyway) so the added > latency should not affect them as much. By doing this tradeoff we get > slightly simpler code (and simpler locking scheme). > > But I see your point as well. In practice session creation and > PRESERVE_FD are independent and one should not block the other. Maybe we > get VMMs creating sessions while another VMM is preserving stuff, and > this slowing down the live update preparation? Dunno... > > I suppose let's go with this patch. But, can you please document the > lock hierarchy where you explain what this lock is for? SGTM, Added a documentation about locking. Pasha