Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1712089pxb; Wed, 9 Feb 2022 02:53:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyM9Sjp147ALR4RBbeFyJjtaelSQxrPrtYoj/3B/qOMe0zoe2w+flZOryxZE/gfQSfaHl2q X-Received: by 2002:a62:1d11:: with SMTP id d17mr1774500pfd.8.1644403984375; Wed, 09 Feb 2022 02:53:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644403984; cv=none; d=google.com; s=arc-20160816; b=taIMddHjejghdmAjbqcQzd6ABBthCs/j2AwrG7414AyEhS/S93qhenVOUrqVOa0L+q 7mAw00vq+cHIM7WDOUDbny/Ns7LEQFN1SV5i8mv0tZZA+WB4JhimZU8W2KXztQk4R8i2 ojPXqhjlIVJc82OS6nSJIlZc/07y/jaKPAqK6At2cW5xJK/Cu/5zhmkpNxsWb4Y4dNpS 3t61/P0M5POTPmBmtC0K5/MnxEDdtN7fvuPis/Mf78HhrZyFVyX/LyPCp4JnJt19/cJ+ BxUFjUNzhgqL/Jt9o5tDJWuzXLZfZVXR3nvAoJcPgMDcz3r8vsfIZBRv1wsCU+xxP3YJ iQTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature :dkim-signature:date; bh=pVIJUQJ0Ki8jKxcVnu+JXzo7n2t1fOshvCE90L4+HCA=; b=1F0bSHRX9RvK0/snqA6uKccKBVgIvaKRPVHdmWcuQP519WPuNyWcmbW9pdtw57sWoJ Zkenu8JQBAyAm0fUvGrJkBeMdxmTe/cvb7tltN5Ji/YoBU20vX4pXt57dUfLnhVUbOK2 wd+fgv4IAymR6VHp73dt6rrO9rjdNDuQjvWZuFygaRcW5FxRHRD356fIDk11BnhTm+zL 2uLZBbX0i8vV+cZz8HVwlrhI8dh/u84b1AE6vEnBn/Wg99T94rlX1gzVB6DY0sKqLK0b LrxdmSMo5zfLB8TiQicQUmkWp6Xb0RFPoC4XcMSF0UQPm2p9FGOcOIw4eUdHujv/S1mU Unaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fMBTllFb; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=OUZleW8S; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id mh4si5317302pjb.38.2022.02.09.02.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 02:53:04 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fMBTllFb; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=OUZleW8S; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1D82DE0BBB4B; Wed, 9 Feb 2022 01:28:09 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383744AbiBHRKZ (ORCPT + 99 others); Tue, 8 Feb 2022 12:10:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244646AbiBHRKX (ORCPT ); Tue, 8 Feb 2022 12:10:23 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82717C061576; Tue, 8 Feb 2022 09:10:22 -0800 (PST) Date: Tue, 8 Feb 2022 18:10:19 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1644340221; 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=pVIJUQJ0Ki8jKxcVnu+JXzo7n2t1fOshvCE90L4+HCA=; b=fMBTllFbi5CRsMKdL3deJDoNDCfPPbH3eUL+Y2farcA0uT6jdIqGXaeKgNLsgeuP44PrzK yJ2INt2H36mQlOu9yeiBxvSY30N07QM/wa521X32ueZA95FcqlMthcy7qv7ZRJ1KMDehao yqR9M9tVyoH7bwbT8OfDlkEGl+YPrI4bWEUeSvgXhnOBXE4dyA96yobaT2A3Nmx7b2QJdH +WIxpstG23uxLa5AgVCNEDB5K70AHkbJqfwyOwJPiKqRnUg9t5PBmAMvTjza5T1vF4Tc9b TXtGTXdhbYFlZB3T0e+8PoX39Osg2K4VrTI2HXkrI6dmvtNAZ2vQLNaCWHgDbw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1644340221; 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=pVIJUQJ0Ki8jKxcVnu+JXzo7n2t1fOshvCE90L4+HCA=; b=OUZleW8SVui/wDg8abv+0fBP7W8jblNX0+mj1AqKnxF/2Tr19Z58pkEFB/x2VkDjxM49Q3 QX1QiPFUyYqqfoAA== From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org Cc: Andy Lutomirski , Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Ingo Molnar , Juri Lelli , Peter Zijlstra , Steven Rostedt , Thomas Gleixner , Vincent Guittot Subject: Re: [PATCH REPOST 0/8] kernel/fork: Move thread stack free otu of the scheduler path. Message-ID: References: <20220125152652.1963111-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220125152652.1963111-1-bigeasy@linutronix.de> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-01-25 16:26:44 [+0100], To linux-kernel@vger.kernel.org wrote: > [ This is a repost of https://lkml.kernel.org/r/20211118143452.136421-1-bigeasy@linutronix.de ] > > This is a follup-up on the patch > sched: Delay task stack freeing on RT > https://lkml.kernel.org/r/20210928122411.593486363@linutronix.de > > It addresses the review feedback: > - Decouple stack accounting from its free invocation. The accounting > happens in do_exit(), the final free call happens later. > > - Add put_task_stack_sched() to finish_task_switch(). Here the VMAP > stack is cached only. If it fails, or in the !VMAP case then the final > free happens in delayed_put_task_struct(). This is also an oportunity > to cache the stack. > > >From testing I observe the following: > > | bash-1715 [006] ..... 124.901510: copy_process: allocC ffffc90007e70000 > | sh-cmds.sh-1746 [007] ..... 124.907389: copy_process: allocC ffffc90007dc4000 > | -0 [019] ...1. 124.918126: free_thread_stack: cache ffffc90007dc4000 > | sh-cmds.sh-1746 [007] ..... 124.918279: copy_process: allocC ffffc90007de8000 > | -0 [004] ...1. 124.920121: free_thread_stack: delay ffffc90007de8001 > | -0 [007] ...1. 124.920299: free_thread_stack: cache ffffc90007e70000 > | -0 [007] ..s1. 124.945433: free_thread_stack: cache ffffc90007de8000 > > TS 124.901510, bash started sh-cmds.sh, obtained stack from cache. > TS 124.907389, script invokes its first command, obtained stacak from > cache. As you can see bash was running on CPU6 but its child was moved > CPU7. > TS 124.918126, the first command is done, stack is ached on CPU19. > TS 124.918279, script's second command, ache from stack. > TS 124.920121, the command is done. The stack cache on CPU4 is full. > TS 124.920299, the script is done, caches stack on CPU7. > TS 124.945433, the RCU-callback of last command is now happening. On > CPU7, which is where the command was invoked (but not running). Instead > of freeing the stack, it was cached since CPU7 had an empty slot. > > If I pin the script to CPU5 and run it with multiple commands then it > works as expected: > > | bash-1799 [005] ..... 993.608131: copy_process: allocC ffffc90007fa0000 > | sh-cmds.sh-1827 [005] ..... 993.608888: copy_process: allocC ffffc90007fa8000 > | sh-cmds.sh-1827 [005] ..... 993.610734: copy_process: allocV ffffc90007ff4000 > | sh-cmds.sh-1829 [005] ...1. 993.610757: free_thread_stack: cache ffffc90007fa8000 > | sh-cmds.sh-1827 [005] ..... 993.612401: copy_process: allocC ffffc90007fa8000 > | <...>-1830 [005] ...1. 993.612416: free_thread_stack: cache ffffc90007ff4000 > | sh-cmds.sh-1827 [005] ..... 993.613707: copy_process: allocC ffffc90007ff4000 > | sh-cmds.sh-1831 [005] ...1. 993.613723: free_thread_stack: cache ffffc90007fa8000 > | sh-cmds.sh-1827 [005] ..... 993.615024: copy_process: allocC ffffc90007fa8000 > | <...>-1832 [005] ...1. 993.615040: free_thread_stack: cache ffffc90007ff4000 > | sh-cmds.sh-1827 [005] ..... 993.616380: copy_process: allocC ffffc90007ff4000 > | <...>-1833 [005] ...1. 993.616397: free_thread_stack: cache ffffc90007fa8000 > | bash-1799 [005] ...1. 993.617759: free_thread_stack: cache ffffc90007fa0000 > | -0 [005] ...1. 993.617871: free_thread_stack: delay ffffc90007ff4001 > | -0 [005] ..s1. 993.638311: free_thread_stack: free ffffc90007ff4000 > > and no new is allocated during its runtime and a cached stack is used. ping Sebastian