From patchwork Mon Mar 11 16:46:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13589080 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 89383C54E58 for ; Mon, 11 Mar 2024 16:46:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 51DF86B00CF; Mon, 11 Mar 2024 12:46:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A7CD6B00D0; Mon, 11 Mar 2024 12:46:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3207A6B00D1; Mon, 11 Mar 2024 12:46:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1DE586B00CF for ; Mon, 11 Mar 2024 12:46:52 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D753980830 for ; Mon, 11 Mar 2024 16:46:51 +0000 (UTC) X-FDA: 81885337422.05.18E0253 Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) by imf15.hostedemail.com (Postfix) with ESMTP id 2CB21A0019 for ; Mon, 11 Mar 2024 16:46:49 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=vs2HnyE7; spf=pass (imf15.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.54 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=WeoI5maDr3l2Ozw1ib0LWqoOcMWVTMRirMYG/aEeKfI=; b=xtAhYSdZ7rx3XVGkYiIW1bzFbACoaqsiBlkmp3fp82Jd6q1s5C9ZuA18NequZJhyYsEP05 lAjr9+CiNPUNtkzhNiKujXoffjprAdeI/a8KOqp756DLKr7V8g6LgEkJAs2JSFuwTgDQxS y0USBIT+sT4YKFJD4Jg239U7SljuVEo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710175610; a=rsa-sha256; cv=none; b=xqSGyWjrZQp2sdTFNULZEm3l5y80Jm6waBiuViVsqoVEStHs/1rgkqSBG9p6M43lUIQylP mEAFzE1TTCbK8vYadkl5WQN23NUAiNRRzYeV4/7uHRDVKHbDQYBC7J9oPDADd1UJoIeRaG /QRv2mH6UUfDR/Kcf75/bbKjpDfzfYs= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=vs2HnyE7; spf=pass (imf15.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.54 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-21eea6aab5eso2878624fac.0 for ; Mon, 11 Mar 2024 09:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1710175609; x=1710780409; 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=WeoI5maDr3l2Ozw1ib0LWqoOcMWVTMRirMYG/aEeKfI=; b=vs2HnyE7s9sCDAJLnnazCeYXed96ZPFn5WCFdgInvLvILYbIhFDB5QF9VuOdWmz2ZG VK8wrEGWd59BfH3T759syZAJsOD0HxO5RS6bEcjPBmy/3jNxZHnxfUA9v6fu1R8T5mCQ O6wUqHfnXhtPKt6eMNBcbePzVKElUEXtAli2TgDOD7k0wSD3WElzhNoXVgYXq9MbQdMw 99nL5JCZzeoLB/JF3vcfC56z4Hn/T5vizDcT9BD3AOfWk2KNhCTwKnpplE1Lg0nHPzkc fu08KjCfbNfSxH3MjHiNoAf47WHtSO9ckm3+5Fa+LM3Tv/vO7jQYqmEkNoE0QyOpAul7 1SiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710175609; x=1710780409; 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=WeoI5maDr3l2Ozw1ib0LWqoOcMWVTMRirMYG/aEeKfI=; b=JwrPMOHnxBcyeY8QoAH+2izMqI/f7c9GwrFWg5P+paLF70f4hkyyA3qz/58lscHDB/ GSOxTzHaGqza6Yfq46FzOWnT24A5rhWZ7CPX4Uu/QRLMv2xg/31H6C6nq+lpNbuvz2eo LjfoN4u4f2PB/bVhTiXXqhZUk9cdsTsbMHgOTx2E0eM0b0ZdtR30mblGYINhpYbCo+xS st9CDWQfVxxxpBemyO9WLZ16ggaGuEfR2d9IXBKjUoiaqJe8xDdDa67EUFxWeXxWJ10O bMjdR7TR2AwGPDyIDMWfBoI9bxdz5GQrjOplpSmsnYtQ+UEDcyndFRB5dw1WBzTB+ByZ RBBg== X-Forwarded-Encrypted: i=1; AJvYcCW5w6q57baByj/PSUaMSxgsp4ViLkoSZCueEJwbhWRXdwH1A1e27lsnaKWM3SeV46hRztwMBaX9qp47Xj00h5azbgQ= X-Gm-Message-State: AOJu0YxLc3ks4DzgDzso4IoPBrgkBIJkVxxJa0wYmVcMTqxacyblGDEg +RHg/WysIPJhTWauy/xt3J2ybqFS9kwKlnlng6PZUCYjzgB5lhcdFrM+GZWZqjg= X-Google-Smtp-Source: AGHT+IF7PMDKY7qPBLzKisHlCeRFB7P9dZ8FJtUn1b4P6yLcZu1GLHtuFZbDu9s9LwmUDKjKkIy2MQ== X-Received: by 2002:a05:6870:3307:b0:221:a43d:60ef with SMTP id x7-20020a056870330700b00221a43d60efmr8059130oae.3.1710175609309; Mon, 11 Mar 2024 09:46:49 -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.48 (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 06/14] fork: zero vmap stack using clear_page() instead of memset() Date: Mon, 11 Mar 2024 16:46:30 +0000 Message-ID: <20240311164638.2015063-7-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-Rspamd-Queue-Id: 2CB21A0019 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: prwoatabfgiukecu5qryyyp54hru7ia4 X-HE-Tag: 1710175609-844928 X-HE-Meta: U2FsdGVkX1+JP8joK4/QBkt9sg6vD1M26dbylAuTnoILw85qmyraXmOkK3xOdvVA0PWbFYBYqY2rUQLn4amuv6KvTfforxqVcpqeJoaz+PKGq5u12Is0sYWVAAVN0vMfOcXwyrHo9JJt2c+u2uPLkv8cLqJ0lY5Twi+Z+EQIrH95J89p9l/NVP7WM1CUEZBuIG75vXCojYW+5VEITMkq8XDD9Z2dXoAr2guZvu8XW2i0nLySGb/3wH59EMY+Z8nHtsCVQNhMpRBf1c53YDxia/1HXnEJ1vlK33ZweVGhQXGdT4ti79pAa4icgX8RoTRaXyc2Ntp6fkv99GlRQ4DApECZ9B+dkit6WMI2OhjOzWGdvwUsfeBA2jugn1Ar8KxEfwPK0zoKoPUiy457VgY5O/27YjoYIP8DbMXriZ9jlIs9coo/s5dND4NK1EPUbIiJYymkBVXXfovmTD3bXSjNJUK/AsQ9bDqjBjn6fk1VE5zxk3TLXy3mPLcyG5nNK8ppeu0cykOIkBQ946QRUtV3YhUuNhS5hVKnB1UqZQ7sc+nkb2Rt9B6bjws7Lvt5+I33eVkFgZJ/ws+UC2RCk7T1e+CtO8KZAwpVaqkOyenUPQeJDPB9xt5nNae03ETR24QLNpaCrwhfGBpib+L9hVucJ/bmP04scUFB0JUfGvFawB5QXly91F0QTG9opXpbG692Ryq1Sq2OooMLdcLLfze4fvZwfQxLAFe7S3EQiBNhrmZWAjS5YLPMn8bwwm16/bSd7j6GAjO3OT328hty2VqSAhJtbBZn6YObRjYGaCrZU8NlneLXBB9xVG3u7ms5gneMQqEqkOujgzHh+d/mYNr9PCSli2PWV8efVcGQvhUlyF5XbQPyixQPUG0f5EpFJS4NwWAVXjghWuYw2tioH18zjK42hzlK1I67afeb/y0gk4nidFU4T3CG7OFkOql3MzAcip0ltC9rQvF52aduJoG UZDrGcon HD8Q4yvMgcj+Zm7s+xGYLGIoqOw0Bj0SDKINHay1bF4EY7TEY9CQCJ2mSS+YqxkL71hFYLIt+ly7tEQW9HjG1ub68mcTuz3pYwTcDN6AZqxbhpeFDVHKMDW4gC+9PCOz7GQIlmdOREkxE+RhQC4YFHmuISAUIRZRV9PHCBtUCdR7JTI/5CN5YXxCXPhoDlRf4jNzWMw0DNnFRzXiwS42DnNsIu80DWpLAPCBm X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In preporation for dynamic kernel stacks do not zero the whole span of the stack, but instead only the pages that are part of the vm_area. This is because with dynamic stacks we might have only partially populated stacks. Signed-off-by: Pasha Tatashin --- kernel/fork.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 6a2f2c85e09f..41e0baee79d2 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -263,8 +263,8 @@ static int memcg_charge_kernel_stack(struct vm_struct *vm) static int alloc_thread_stack_node(struct task_struct *tsk, int node) { struct vm_struct *vm_area; + int i, j, nr_pages; void *stack; - int i; for (i = 0; i < NR_CACHED_STACKS; i++) { vm_area = this_cpu_xchg(cached_stacks[i], NULL); @@ -282,7 +282,9 @@ static int alloc_thread_stack_node(struct task_struct *tsk, int node) stack = kasan_reset_tag(vm_area->addr); /* Clear stale pointers from reused stack. */ - memset(stack, 0, THREAD_SIZE); + nr_pages = vm_area->nr_pages; + for (j = 0; j < nr_pages; j++) + clear_page(page_address(vm_area->pages[j])); tsk->stack_vm_area = vm_area; tsk->stack = stack;