From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57EBAC433F5 for ; Mon, 14 Feb 2022 11:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344867AbiBNLpf (ORCPT ); Mon, 14 Feb 2022 06:45:35 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352634AbiBNLom (ORCPT ); Mon, 14 Feb 2022 06:44:42 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE687C52; Mon, 14 Feb 2022 03:39:07 -0800 (PST) Date: Mon, 14 Feb 2022 12:39:05 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1644838746; 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: in-reply-to:in-reply-to:references:references; bh=DXbq0tADiA1e8237ZJnCsYfJ4qqjQmGrNdy9V8g+GD8=; b=MIiAp1avZ4WyMS8mF/E2GKZM9OsesUa4wuZ+ixeqoeujTMMLvtQ0AQPX/wyEHQB9gFL3gf YrYeTAd/klUck2UDc6craKnXFy+Sm76fccwAo6r/MBtVZ/KMWhW0AZeofYEASqVkXjQmo6 +xljGrriNUzLFvHucdjvoSnz6z3fIEzMOG2UhFTDjmIkRiKIcvkPqk3ED35MxsMUn1aJQo IZQUlSIEZ87Wy4TFSV7sYKZnOShkGI+wDiG7h0Cm5jiOwUAq0iYkK0GUkQ9kWR+hKG/uGw Bi+Acb7TuHb0o5szOLG1g1T1ncTjS22SOm8XxeNmXWxwlXt0DS8mKPL2YqBlyQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1644838746; 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: in-reply-to:in-reply-to:references:references; bh=DXbq0tADiA1e8237ZJnCsYfJ4qqjQmGrNdy9V8g+GD8=; b=7xLGTC0gx0WKqfra9wO5jaCeW5r8AGDWDARdETFncnR1wpChCuFG6cVivCIFOCHkRf8szn bg4+mhZsjdCMqCCQ== From: Sebastian Andrzej Siewior To: Andy Lutomirski Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Ingo Molnar , Juri Lelli , Peter Zijlstra , Steven Rostedt , Thomas Gleixner , Vincent Guittot Subject: Re: [PATCH 2/8] kernel/fork: Duplicate task_struct before stack allocation. Message-ID: References: <20220125152652.1963111-1-bigeasy@linutronix.de> <20220125152652.1963111-3-bigeasy@linutronix.de> <8340d413-4951-5e62-ef5f-f396523edac7@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <8340d413-4951-5e62-ef5f-f396523edac7@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-02-11 15:42:38 [-0800], Andy Lutomirski wrote: > On 1/25/22 07:26, Sebastian Andrzej Siewior wrote: > > alloc_thread_stack_node() already populates the task_struct::stack > > member except on IA64. The stack pointer is saved and populated again > > because IA64 needs it and arch_dup_task_struct() overwrites it. > > I understand the problem, I think. > > > > > Allocate thread's stack after task_struct has been duplicated as a > > preparation. > > > > But I don't understand this. How does this patch relate to the problem? So I duplicate the task-struct, assign the stack pointer in alloc_thread_stack_node() with no need to update the stack pointer later. Otherwise arch_dup_task_struct() would reset the pointer. > Also, you appear to be missing a change to the free_stack and free_tsk code > at the end of dup_task_struct(). It looks right. What am I missing? Sebastian