From patchwork Mon Mar 11 16:46:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13589082 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BDD3C5475B for ; Mon, 11 Mar 2024 16:47:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 128F86B00D3; Mon, 11 Mar 2024 12:46:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D6A66B00D2; Mon, 11 Mar 2024 12:46:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB9266B00D3; Mon, 11 Mar 2024 12:46:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CA2DC6B00D2 for ; Mon, 11 Mar 2024 12:46:52 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A3C97A01F8 for ; Mon, 11 Mar 2024 16:46:52 +0000 (UTC) X-FDA: 81885337464.29.F3C8FE4 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by imf06.hostedemail.com (Postfix) with ESMTP id DBB18180010 for ; Mon, 11 Mar 2024 16:46:50 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=DX4pdb0K; spf=pass (imf06.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.172 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710175610; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rWA/mIcrC8mrdgOBIz97cH4Ahtr8zqihEDBDcy8+bis=; b=1AOy/9XS6gZqCi+v5G+80+BZl1KqqIvgiAd9osa1UOCoW+q3PpKgSfEZuA0JW3ZX8do+pQ izmOZRvvYKZmptxVASh3M5DIVNDtqYqqBqAoNNkcMfOeQURK5iTK8sJsMsEfILHHvMJcj9 cJZGnt0Zs2qPrw6JGnfQBq8zRoC2dJk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710175610; a=rsa-sha256; cv=none; b=IOIloGpW6yuCWaPwOOq6biJAUI+4C2N4FMje54JWTF2a47Obi7wJmBiP0Pw7LhI41Nc7eq GItlaCTVr9FER8fpy0uq+IQLEDJCYCVH5qwtttwISUvoqMixoT1LkdLLOWT+iqb5VJGJS6 /6sMm8lwzhUmG9uJnxUxVEQ8xuPMY2k= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=DX4pdb0K; spf=pass (imf06.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.172 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-78873ff1202so24555985a.3 for ; Mon, 11 Mar 2024 09:46:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1710175610; x=1710780410; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=rWA/mIcrC8mrdgOBIz97cH4Ahtr8zqihEDBDcy8+bis=; b=DX4pdb0KjNr/ebcTqoXy/d4fZUONR6bc0FWsqFXABcYVp93OvfThWZWC9dNqQvbwEQ jrlnmOYSBa8bTxy/N/LeOOHcv7q5UagNW4vOKC45fwN1uYX+2lR7BIQ32GhFfm8i6tkZ gzRaL7zwQeJUT7dpGN+zWYmPAY1zLO9dt5Fr4NyjyzNHASnOjDlIxalNHxW7jFcply6e PuVhmGdCG2XUeH8Sc7bZrS4/hAc6nHDxWI2b4NqjZN3Rls+WDRolJe1bXHPxbja0J34f B9ACKwVW+BTL55j3ZfQeCSZ0DBOFQgsrs5zmquClDHEawwCpE7SPEkbozeKc7aps5hrg RE6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710175610; x=1710780410; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rWA/mIcrC8mrdgOBIz97cH4Ahtr8zqihEDBDcy8+bis=; b=nHxKMwv+/LK20+v+7v4izK/mY22SBGUmsMYuMMAgerSELahqpCHY7UDaHgQ7IhP7/Y uiGVmp0zcaawlriOF6csCjcoSVWAXczbHuvRX8Ln9Oyg8XjjntgIyW6/YKYZWwmy+Yyg rkjvMa0rAB2IMYUzcwjee8Si2Ltf4Nen5wMag1n1W4Tpny+iCSRuJRPi1IISb8ksRN6a c9cHMxIl8UOkDKnJUaxePohaPd3Atj0N0hJ0WSonZcMTLVMEX0IZYo7yMdo6mwtG6Zxq BkVCWc3pAHwyl/zW2DlzYEACh/e6YUYyb0j5/pS7wgPa8E4lCCto+GkfqmIq5av6sb2H Mdxw== X-Forwarded-Encrypted: i=1; AJvYcCXzTL7bfidFNkWl/ZWZy/edvjywyut7r/gwdyHrKAQvmO752zBtciqi59GMI8YpIikDW7hL1CVxAy02iiPJCvYG8Io= X-Gm-Message-State: AOJu0YyP8HeFTjMDbf1GufZ7oHIcWL9T06JwBOKdwRXKtzvN4cae3JWm Th74RZEs+cCTaeoO0G0hYjNdpRlY7f8F8ec+PiceVmEmKJITiccvfezP45YurdM= X-Google-Smtp-Source: AGHT+IEiaWGNP1LEtKt9OxZe9a0Ecsughs1hTC155ICY2/6rd+mLJB7PdZHKC0eSeLtAUcuC8VPmXQ== X-Received: by 2002:a05:620a:222a:b0:788:61ee:7fee with SMTP id n10-20020a05620a222a00b0078861ee7feemr6338288qkh.61.1710175610089; Mon, 11 Mar 2024 09:46:50 -0700 (PDT) Received: from soleen.c.googlers.com.com (150.254.86.34.bc.googleusercontent.com. [34.86.254.150]) by smtp.gmail.com with ESMTPSA id d27-20020a05620a137b00b00788228fbe05sm2851589qkl.17.2024.03.11.09.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:46:49 -0700 (PDT) From: Pasha Tatashin To: 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, tglx@linutronix.de, urezki@gmail.com, vincent.guittot@linaro.org, vschneid@redhat.com, pasha.tatashin@soleen.com Subject: [RFC 07/14] fork: use the first page in stack to store vm_stack in cached_stacks Date: Mon, 11 Mar 2024 16:46:31 +0000 Message-ID: <20240311164638.2015063-8-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog In-Reply-To: <20240311164638.2015063-1-pasha.tatashin@soleen.com> References: <20240311164638.2015063-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Stat-Signature: 1rpajoc97k6ie78t46zx4i1fax1prout X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: DBB18180010 X-Rspam-User: X-HE-Tag: 1710175610-983636 X-HE-Meta: U2FsdGVkX18UeNNFj1vlJqT9wb/rwD/qY6eF/G7zB11QJnRZA2Yk8qay1uTwZFRLI2O4mX64Sj4VNR//25Vw1D9mHYBio1bDCoi4ZMSuAdpQIQXeVnlzeqR7aPZ8G5DlWpZmyDWT5kjCu/RxUpc9u6Ib6Z4Tu9EBAFKg+F2dNW/n0OzMDLhXci3Y1e+zjiqTXIe7mBRY5tr7umqUPUMFh/LTWF1EWI+PThXLNdvQalK2sBmwPhOjIBYnsdVv2PI+zo3KaPsChh/HJxTup5g/5Mn5+DQHiwyQ4jTY4WY3JUCSJ2aZZa1NvL6cItc5LcNkG+OvN+/vgwz/G3Kb5ilG/atH/rbUOaHe4+SU5jZ7oGVG50vfj8hFuGzm+S3dSiWVCbIBCAgv3Kjtp+nhqPXS5irT8ra/6T/mA2hYqi1OLpVTtMmZxNCUEhp02iFxB7+TzPt2ssBJw5DnuY6WYz3IXwmogKNk90deJEqvbMg1KlGTeFX+Obpgvzbt2jGzMIfstwYj0IkNs4VJ69BRvc/EATJQMEG+cblYQaZqMjUZliQYEaqWzDjcBD6yg4CnsBFUag3ahRnKks3AtiBF5bKzMiHOOB8TYA0V3NSPxGusFz3HvU94ijIfbvyVSpw8J9Ky1T0g9L0OeiThFyKg1p1B9pAXf6BZuMuzGsNUJQuhO2mQruPfeLdC/nsTei6zmH35UG0Wm6frnrgQvf0yQdagTs8sLMLiw9mdboFM46nV2vJRA4lEcL8vpmDD6D35WwX3F11Yh3+BPrWVUa2mhAsP4uiEfa3GmrmWgT9QjF3/QWEQYaYuvVeyVdbnjLT6p7/E27gc84XC4Pl5H3aop0QUPF2mYdMwZyc6ONkQggq+2BlbRCunRmr0SQasKXoK2qezuuzbogWgxWdAiflv1DGgjxFfyQT7UtBfHAR4RgHOFpdi06Gj/mrSf4TR9KK+gHi/QPFXv2QdomxgeJD/hHL aMUDu7TX 5sAqxYC+YZCMc6XYyn1Nwl3qSUzK+a4dSOq9tuOAhNXDdepIPt90vQ/2pjuUUmaUdNebvvmbHuaNdew3nGqWc//UxaZLTLSPjT8lg2bAm9C7wktctlM85uGVXsU9ngt2O4nXDCgorf20ewXtZABBLg25h1FP+VoUod95/7IW80isG767D6tQUogiDKGR5+j5D2jn0L59cIikGNdp6hxwpQNqkvUxL5NJ5awZR X-Bogosity: Ham, tests=bogofilter, spamicity=0.000051, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: vmap stack are stored in a per-cpu cache_stacks in order to reduce number of allocations and free calls. However, the stacks ared stored using the buttom address of the stack. Since stacks normally grow down, this is a problem with dynamic stacks, as the lower pages might not even be allocated. Instead of the first available page from vm_area. Signed-off-by: Pasha Tatashin --- kernel/fork.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 41e0baee79d2..3004e6ce6c65 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -217,9 +217,10 @@ static void thread_stack_free_rcu(struct rcu_head *rh) static void thread_stack_delayed_free(struct task_struct *tsk) { - struct vm_stack *vm_stack = tsk->stack; + struct vm_struct *vm_area = tsk->stack_vm_area; + struct vm_stack *vm_stack = page_address(vm_area->pages[0]); - vm_stack->stack_vm_area = tsk->stack_vm_area; + vm_stack->stack_vm_area = vm_area; call_rcu(&vm_stack->rcu, thread_stack_free_rcu); }