Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp886470lql; Tue, 12 Mar 2024 00:16:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWAXaWy7ry81QBQ0FZl9U3knoKYhO9/4s6SztXuIunvsT6XUw46tiUZqxSEF6ubwuwfIzTljzy3Zr1CSyrWO36BwsDo2v5uJcVwD9P8dw== X-Google-Smtp-Source: AGHT+IE7Bgt+JG09pG6pTDlXiAGYjey//Ij1Ypgtm3c8BeHmwLKDLFlaaKuezSXnkgEz7mc2fq6y X-Received: by 2002:a17:907:104b:b0:a45:bcac:c7e0 with SMTP id oy11-20020a170907104b00b00a45bcacc7e0mr5234995ejb.65.1710227775731; Tue, 12 Mar 2024 00:16:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710227775; cv=pass; d=google.com; s=arc-20160816; b=zhtfdTl24kIVYHU44xxzNIGo7fkqCFjqO7dtZal/D9kA2Gpev23V6Snc5fPSxN3zOz l9Wkj40iBX6rAcT+00r2NpLBZKmjkRnj/ys2UUSZ5z40wiXwVHESG9s0xOzcvhhiGatf iac2yKOzJ7oeqovNN2Nvu7KZac+0JKrVodW1TR9eiHoD4KfRTQt3ZAZkBNRbubbfK2dB hjC7At2nw3+I3xiAErVd0hOMK9G2nNt2SMZZscfOrP7yfiO5pnqRpKFRYOsHmAZcjQ2w K2ALCe1EuNIp1jpj6s+YTUDIrWrGkMqFa9tjb2pcjsNwOHHwDvWjVzU5h37um1WkIbxd aZ9A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=PFX7WVCFYMo7B4UNiqmgghk8AAJ2gObVtvPhC7KXN2c=; fh=0prQP2KG8v7A3CL+yRH46IZ5FKjbIQvKU4PivKhkGu8=; b=VcHGUK2R4kW7+mI1NwuBgpDJicsmu/cin3VuTPKKm+LGb60csnwLFBXpvNaRgnf5P+ NUp/pf57aD1yqukmM8TjRCdS+6TFrZ3khoNbcxNdGh/4mPXJ0VK/Q8xjlaKXMVi0Nhop mBtA8VL96OsXOTFdMpGbcD/iIDBx0wqrJWq6ukljgSJy8X2nOKYNv4qGZV8cjY9ywDln sopkjJXMd6dAwxDKV/eZ7nPhN2gysWHb1XmfE4XLfFLy+6VbW9LBYXn4NBI4w9kSYysX ndLPntpEJbBoTLDY2oG5bhs00BLriB2TYgDMoQNXajsW0YsC/ct2dmjj3K5HNUC2DWxu 82kg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=EtyZDW4v; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-99907-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99907-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id pw20-20020a17090720b400b00a4444ff5c9dsi3022435ejb.244.2024.03.12.00.16.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 00:16:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99907-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=EtyZDW4v; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-99907-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99907-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 55C161F225A2 for ; Tue, 12 Mar 2024 07:16:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F54B6995A; Tue, 12 Mar 2024 07:16:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="EtyZDW4v" Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (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 7ACFC3236 for ; Tue, 12 Mar 2024 07:16:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710227769; cv=none; b=Pkl2OaR5f9Jvl7PP1scRwyc54XpYgt4GwEpHxNrDQXxy7ut2dvt/AFAfJ1q+N9psqLAI/PrpXz3CtfBAdmZuELnId3KpRvietXoM9mO+HKwfIUxp8/D6T9L22zR885dejJ7o0Xj7CQV2HQ4ZN8KPURLe/fCEsZpYSTn5BKvkJx0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710227769; c=relaxed/simple; bh=emW0M3FKBvoz37Qj9hHkGiFe9VwEqstLXzaRCqVisYk=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=eCDDPU7LZSn44i2PgMw59Zk8oXlAEOmA9dzGcN8tQ0poXbeMfbU+OSbkHZaF4hP5fdLbBhpaJkBFIpnAOowXVfAVZLbugmvs4Zl4+m/Rs+kEgJ7lykivuv1591pk1sZ5I9Vohil9o40mpSN8VdPPNWJZwzAnnSmW5G4JHMMMIpQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=EtyZDW4v; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-564647bcdbfso4091149a12.2 for ; Tue, 12 Mar 2024 00:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710227762; x=1710832562; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=PFX7WVCFYMo7B4UNiqmgghk8AAJ2gObVtvPhC7KXN2c=; b=EtyZDW4varAMMMgSEbJ0t5MIqPJMh1e7ssTbVKmroXiJ/88AsAE0AEjT8bhTWMg1nA lwwn4mBYYwAgL3HqX0mSMhMeNds8Pd3jTy4e3jJjbkAocPi53du/zwYYVOfr8H9v0ZP+ NBRSmRsBSeSM2BB35+nfqjhuu8zsiUNOxVAcQgWFoCyE7Ajoeac8m5LQqqsOJ9F4+xe6 d2aHjLO8TdbmBTHWONuQnn2jc+yMxH8m0JgiBhXHqM9t3KWhNI+h+QvylgjmUt0ubXSb +oy5hFlQGqKmE5fNUYQZ9LUo49VPlle97AMBFWfDMr8YHnnXNrd8/l9921psdfpAdFjV kk5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710227762; x=1710832562; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PFX7WVCFYMo7B4UNiqmgghk8AAJ2gObVtvPhC7KXN2c=; b=kajKyCAwPOzbKRwcmEkB2L/wjwmhwJfuAnUeYulghHyHWS44fGqrNb07QEcBlCRKub todXS0E6s5WK5cX95KHPO2D/N0mNyDRzhPhR6EY8zQpJt61PZ2EFYL4YdGVTCPcOpAU5 FFSoKooa0ZNAoGI69aMCN2jApSkgN3AkohbTemqFUxCJMqeQ1fACyZZYc25EjzxDRsFh eBlsfhGKRj/dn8Pj1oeNpydl2XX+SGe0NiEmQ3XOqRBgTaHpqsMksGf9sP8Qv81Uc4tW yWoJXmgm6MfYvT7aKrL+tuwCsAKzIB9p2UEXcmcKCL8f2y9Kv+BcYs5n+ixkeJhKau+o 1D5g== X-Forwarded-Encrypted: i=1; AJvYcCUayS7zf+NZpu7CS5acWgBqBH4/oqwkdyWE3jddt7uCz//sLCHEy4k3tO/dgPLhx28SXWizoEEMUR06lfUjA4fBjG72zX/PcQaY36Ps X-Gm-Message-State: AOJu0YxxR3EMumKPQGQ8CobYFSojYhd4ManJgMl4d1EOH3lpIxjHc9dX UWCDPbFB4sypzKbVNrFTjhTF/ikPgxOSotBaYQoh+LOOQ7+BzX+w1CWUgB4r7Y0+hWbbst/Qje8 bF8Y= X-Received: by 2002:a17:907:d40a:b0:a45:2f1b:c07d with SMTP id vi10-20020a170907d40a00b00a452f1bc07dmr6413274ejc.10.1710227761705; Tue, 12 Mar 2024 00:16:01 -0700 (PDT) Received: from ?IPV6:2a10:bac0:b000:73a8:7285:c2ff:fedd:7e3a? ([2a10:bac0:b000:73a8:7285:c2ff:fedd:7e3a]) by smtp.gmail.com with ESMTPSA id h16-20020a1709067cd000b00a45f63d2959sm3538740ejp.210.2024.03.12.00.15.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Mar 2024 00:16:01 -0700 (PDT) Message-ID: Date: Tue, 12 Mar 2024 09:15:58 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC 06/14] fork: zero vmap stack using clear_page() instead of memset() Content-Language: en-US To: Pasha Tatashin , 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 References: <20240311164638.2015063-1-pasha.tatashin@soleen.com> <20240311164638.2015063-7-pasha.tatashin@soleen.com> From: Nikolay Borisov In-Reply-To: <20240311164638.2015063-7-pasha.tatashin@soleen.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 11.03.24 г. 18:46 ч., Pasha Tatashin wrote: > 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])); Can't this be memset(stack, 0, nr_pages*PAGE_SIZE) ? > > tsk->stack_vm_area = vm_area; > tsk->stack = stack;