Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp297286lqb; Thu, 14 Mar 2024 11:26:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU65Q4aJhNgNPRY+8sg63OZZPBiz1cLBpBmVj/GFyznw1w3GtrFB8D9HV0IyAKzRQ61BsHwS9uFr1AZu1rupu3gCdxWER9edXIaZ/p/eg== X-Google-Smtp-Source: AGHT+IE8mEweW3uBS0DgXdGcpKLEuNChP12cgewMvymuKv4dJCGkRPma4l8lHoiyl83+vqbtnIcP X-Received: by 2002:a05:622a:1388:b0:42e:ab25:9526 with SMTP id o8-20020a05622a138800b0042eab259526mr2209169qtk.67.1710440785876; Thu, 14 Mar 2024 11:26:25 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 11-20020ac8594b000000b0042f5160c808si2005755qtz.628.2024.03.14.11.26.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 11:26:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103665-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linutronix.de header.s=2020 header.b=vGhQHSyC; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-103665-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103665-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 98E401C21100 for ; Thu, 14 Mar 2024 18:26:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1819474BED; Thu, 14 Mar 2024 18:26:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vGhQHSyC"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="yuhs32qs" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B8F31A38D0 for ; Thu, 14 Mar 2024 18:26:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710440775; cv=none; b=DcALtWugWDF+bHpU2owTzHkvD2wzZ05QPmwObi5XI9XCI755ROdYao+AWzPyiub8wNorhJpkjIIUANJMITIB2DH5upLJLmnzQrrkhKpF4sP345xWZ9Wjq1BaU3ZBziDFY7eRo/BXIcYAZKDKtIdkv72MiJ5csh5q3ds85AHf7Zw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710440775; c=relaxed/simple; bh=osRkPii/Ul1NhhSqCxFUuSOok2Fv+oo6eZSyDcMKXjU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=CKMb5POuOBTokNz8Kg5xmZfEkTDlQOMU4F5sK9IrmmW5gz24/jAaur8MjaJrXr0DFZ90f6bRd+FKPTyhmQ6nrOaROaUN9E+x5FMvm8NZSOM/bPGziHgeoX+WHkrbKY3bypKoj5Cn8Hpp/oKk8xSltP6chqEInvfTBQjPg54WrMk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=vGhQHSyC; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=yuhs32qs; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1710440769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OT14uNtw6W0ZjCQ33RZUVgtWubWcRnNaxohmLkNQdCc=; b=vGhQHSyCkQ0VUh5HYVjZVY8hylof6whCFJs79bZ5Lt0/fTGSh3dZ5z3y/GoxFxfehu8CSz bqRZgCKXGr0xSC9T4RmgKrT1ivs81KeAQ/ZVpbZWG6rV3bx62N/RtzgElCySvi62plzY0v JH0Q1trQw1LjwKaQv3gwl++w4PGKCFm3zXOH8FOkSWJ8cDx3JMkfjZUFW46hiLM7f/Jldk jqBq1Ugk5W1v5VpUB7Butgr1eWGtfIo9/kQo5T99WvhjvG1DNXWv/tudj9xFRf2qtUwHix r8ZtYQ9pmB4y12/mjXhaYV8CCNBPYcrD35j6DO5dkkg5Z7NfMM1CiJG+cbgS9g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1710440769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OT14uNtw6W0ZjCQ33RZUVgtWubWcRnNaxohmLkNQdCc=; b=yuhs32qsRTZnBHrQkpPUXoqiyigddgGgWFc3xDguGV11mBHpyuFVQtHxsHdAzZXLBoTCDl UPdtLeS1DC9pP0AQ== To: Pasha Tatashin Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, x86@kernel.org, bp@alien8.de, brauner@kernel.org, bristot@redhat.com, bsegall@google.com, dave.hansen@linux.intel.com, dianders@chromium.org, dietmar.eggemann@arm.com, eric.devolder@oracle.com, hca@linux.ibm.com, hch@infradead.org, hpa@zytor.com, jacob.jun.pan@linux.intel.com, jgg@ziepe.ca, jpoimboe@kernel.org, jroedel@suse.de, juri.lelli@redhat.com, kent.overstreet@linux.dev, kinseyho@google.com, kirill.shutemov@linux.intel.com, lstoakes@gmail.com, luto@kernel.org, mgorman@suse.de, mic@digikod.net, michael.christie@oracle.com, mingo@redhat.com, mjguzik@gmail.com, mst@redhat.com, npiggin@gmail.com, peterz@infradead.org, pmladek@suse.com, rick.p.edgecombe@intel.com, rostedt@goodmis.org, surenb@google.com, urezki@gmail.com, vincent.guittot@linaro.org, vschneid@redhat.com Subject: Re: [RFC 11/14] x86: add support for Dynamic Kernel Stacks In-Reply-To: References: <20240311164638.2015063-1-pasha.tatashin@soleen.com> <20240311164638.2015063-12-pasha.tatashin@soleen.com> <87v85qo2fj.ffs@tglx> <87bk7inmah.ffs@tglx> Date: Thu, 14 Mar 2024 19:26:09 +0100 Message-ID: <871q8cmzzy.ffs@tglx> 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: quoted-printable On Thu, Mar 14 2024 at 10:03, Pasha Tatashin wrote: > On Wed, Mar 13, 2024 at 12:12=E2=80=AFPM Thomas Gleixner wrote: >> That needs to validate whether anything uses current between the stack >> switch and the place where current is updated today. I think nothing >> should do so, but I would not be surprised either if it would be the >> case. Such code would already today just work by chance I think, >> >> That should not be hard to analyze and fixup if necessary. >> >> So that's fixable, but I'm not really convinced that all of this is safe >> and correct under all circumstances. That needs a lot more analysis than >> just the trivial one I did for switch_to(). > > Agreed, if the current task pointer can be switched later, after loads > and stores to the stack, that would be a better solution. I will > incorporate this approach into my next version. No. You need to ensure that there is neither a load or store on the stack between: movq %rsp, TASK_threadsp(%rdi) movq TASK_threadsp(%rsi), %rsp and update_current(). IOW, you need to move the update of pcpu_hot.current to ASM right after the RSP switch. > I also concur that this proposal necessitates more rigorous analysis. Glad we agree here :) Thanks, tglx