Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp539820lql; Mon, 11 Mar 2024 09:48:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUgFpcp5OV3wo6XfD+eC6iUGghk3oxtuK+RPjuU3D5u/DHSeHCupjhGoPfF653IUx9LlzL31E+vqMv25mjeogNTijR5Hp/Q7JysNTUa4g== X-Google-Smtp-Source: AGHT+IFliSpT9SEzcIpae0CRZ/ii0u1i0z9VFFUlSx28FolukzcWjvJ2gUWRxL0ZjQnfy1KH6Ygx X-Received: by 2002:a17:90a:cc01:b0:29b:b28d:ac66 with SMTP id b1-20020a17090acc0100b0029bb28dac66mr5913103pju.5.1710175703164; Mon, 11 Mar 2024 09:48:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710175703; cv=pass; d=google.com; s=arc-20160816; b=xKSJFczZ5x0laguEpACNUzuMD8niwoML278yaWmzcFzGLlO8FFJs8X9MGdAsHKjC1+ lebWUUPUeFJWlk7Le8w2WumjwF7RYZBp3ueDJSI6bOOcUTqbasbaq6gPlislFglUCGsu yDarvIV8we5SoNtFH/a7JFKgZJWadRbQrDc/cmxZ0+3gDBVtM4yZHzGvl0+LLrMvxzO5 EKPRlxfRab354RJMEhgv7m5FpQxlPyAWAL2oKhMq82cyM0iWa9RN9x0376L390R/Jx4q 2CbuDNcjgtw06mRRJQ/L1Hh8hCxZP/BTz+TqWiEn7ihNvOntVIPZo1nM3z+ZlbjBa/bn ftIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=rWA/mIcrC8mrdgOBIz97cH4Ahtr8zqihEDBDcy8+bis=; fh=kQiLOTmmTYT/RnYbETsrCCUkzAGxYfMbAVQHF5Hzuqo=; b=0+42jc2Kr9gI71M3S9PXS2a2r/naw5t+1ToSQl2F20FtkGWAlzCGI+jLoDeXOUBkxN ReIP7MhnNYgR4aeOULgkoZXeYHNlg4ldBgbmy6ZV3ast2uqOiVn4TGzkfwKIJ1T/hWgB VJL6JYU6ZFQUO82djmyV9x1Pdj8/mP9BDH4o324t0hMiuEr8xoDgZtT8Yq+eLiGyurPs xETwA46COz08tCwViM6t+9hQanVe5pxahdjbtgP0h+vvwyqKYDm3GU10UqKWKow9Nta/ lP60zGZdv7HPGTtlVUFvqUZoB3StQFSlbGA69XZLLgTw/Ouw8pJyk8wkBqgRXI6/8hD5 78PQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=x4cYnBIT; arc=pass (i=1 spf=pass spfdomain=soleen.com dkim=pass dkdomain=soleen-com.20230601.gappssmtp.com dmarc=pass fromdomain=soleen.com); spf=pass (google.com: domain of linux-kernel+bounces-99264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=soleen.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t3-20020a17090ad50300b0029bc3080881si5290310pju.54.2024.03.11.09.48.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:48:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=x4cYnBIT; arc=pass (i=1 spf=pass spfdomain=soleen.com dkim=pass dkdomain=soleen-com.20230601.gappssmtp.com dmarc=pass fromdomain=soleen.com); spf=pass (google.com: domain of linux-kernel+bounces-99264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=soleen.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9BDC9281FAA for ; Mon, 11 Mar 2024 16:48:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E254F54FB7; Mon, 11 Mar 2024 16:46:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b="x4cYnBIT" Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (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 833FB53812 for ; Mon, 11 Mar 2024 16:46:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710175613; cv=none; b=F9+CmXZ3D2pet2fU+1QKd8SDqr/OSXkJKLboR1oXQrscKggffNKQ94Lu6gCwVSL78aOjiMnJaHsri5NV8O3hKM3AYRmtLFPI/8rxillM00GtIHayAA2FFgjttcH0g/Rvd15jXjFHoNzcoOKx1Qhcsq2FbSGccRxOCSyje8Ja1Vo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710175613; c=relaxed/simple; bh=8aZV0c0PfVdZg6NDBVhtRXWK2FtIZwb93neqMuTW6Ps=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ayRgl8R+nvu6kV/U26Z8/3/39GM6O/C4jOym58HBLOSv7KUg2uoj0Os+3zTu5PJAbTasrq+X7dARLLioPKbZG5H655pZ00BVKGVzuzKCXMIWu+ZX4aeg3osW7nK1ll8slcPvVAw95oJ4fzKWWq1lwcLoHUIPu3isBMk+TS3B668= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b=x4cYnBIT; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-7810827e54eso353132285a.2 for ; Mon, 11 Mar 2024 09:46:51 -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=vger.kernel.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=x4cYnBIT/IQbSylpX3UpfrfFC/Z72RHUFvVFLGZqwp/J4vb7SmcvaFqrwNiUb3aPRf /Rbr2D2lm/3xJSGzHcZrbkSkVCU01j/H39sKYNJjohOBKok/2scoPLXuliNpzobfHzcC oBsF6QIj1zf6NvKd/Wj899qN+g73AduprtaHmXXUB8GRCgu7MQsoVDw/QJ/8gxeLSzso nzOPrmOiWnmDgHEQ6D+0WbfUbfpg+59e0TZYDHHYoWmSjDUHnoC64ntdqFpZ38HNzKC1 +Dn1WzNZczvRmROOcT87+XwtlRV9v0d+WzJclITHEJiYpA/a+aNKakcHllbIfMKgNpBU d0VQ== 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=eQonPAcciYgh1JGLPKsqtgAap6jFzQFpjHHwWhFDl1J3PQygAnhReZHq0PGL2aRts+ /+6fCIeDm85P5PcvmYljwUPCBlb50DpaDyLe7Uc3o6RiQSpleGE+boiC+YQa6qPar17V AVo/fCd09RMbgBEMkmiUrMMeX6xliG92V/ZpAyrg0gG5A+HqjqyDEakjGEvUXUJLvUT1 XW1EOjPFFFr9dIHwKINQtQY16XNRVJnJGtXp2FNWBmO7kcSnSJkEBSYgQbcX+RBUTsvU DnTBWr66D+cnF680FiQyCoh5LKdYTyLro1kdRZ7EXtZqvPzrFy37sN2HOQSNIhp0h+HH TW6A== X-Gm-Message-State: AOJu0Yx0A4G2CKIzuV7zIx95Lbl5BKAFORfS2eFVGJItIc0fg7kSceXH MQwmsolFpW6s9CoXiIsAZAPqJfSnkQ6sppboaNHJQckrYfV8Zsv3utnvi7ysp9SN6pK7nvBkooD IwZk= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); } -- 2.44.0.278.ge034bb2e1d-goog