Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2867126rwb; Mon, 5 Sep 2022 02:51:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR5cFFKfrrBrquGso+D3U2JMpNbRI+rDmqum1uweGidskr2uVCkk/uYg3tAyhURKA5SVgP8d X-Received: by 2002:a17:90a:70c7:b0:200:8b98:9afc with SMTP id a7-20020a17090a70c700b002008b989afcmr35276pjm.236.1662371513240; Mon, 05 Sep 2022 02:51:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662371513; cv=none; d=google.com; s=arc-20160816; b=uHQVsS9aLN0QrbZepT3bGPw03lQUEILjzneRs5LLN/Ip5/9J2qn39Zb7Cgm0qxnNKd NevDZwsn8/w1JtTnMnnvBQL0ATZRr9McPsOmQa1OFe+6D7mKOYIQLWC3mT2oaVB7Royg yXdcXD1Ao5aEGP6J2ycbrUvn2Sxzb7HQPMpqmx+Upm4Yojr6FzVjGOJsfFEmWcmB74iV lzxLpPRe+PNu7AcaLBAbPRu4s4wmPOIt1S/8GUizUskOpb3AZAEKJ11xHJqd7MsuUHcH WAYlrPj2rGnS/Ps4N5w1CUIlMg3Uc8JOYek8i+ORLEG+ImWdn5g5aVBXF/DppshPuiOC +J8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=5D/fS5JdX1Mm6MwsKi6+nOZVIWJHcskNeXH+ssXfWc0=; b=PGAQncCbhRSISleJDf1rABFh9NKsdjqBLlYH/54qcff9uLoQBAaWeiLeJ+U9JSdjRu RTy9Jw7PONFCmTNpq67s0dmOsOlTXT6OlfkSqdHh/kjmIT11BC2otWDjWrC+vtZ5AvYz G9KV4K1uJaa9nUNuwAq/XPVd+YgMFK+H4M/QyRfWeUIE+UY1Z/GlGTOIYcUod2gqi9J+ +Jyv7MSmSpA4zPMSgImagp4r95yYuKWHlTkhIjDoc0hbamtyYPNoU942gnJfj4ZV3LHR ScdKB7jNCkFqNAiB2k4ih8gH8vy4ikJK22GiYYH76BsK19iVfwXqd+3rRLH9o8bbwPjI 86zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j36VktyF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l19-20020a17090a599300b001fdcb564d7fsi9360945pji.158.2022.09.05.02.51.39; Mon, 05 Sep 2022 02:51:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j36VktyF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237615AbiIEIg3 (ORCPT + 99 others); Mon, 5 Sep 2022 04:36:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237886AbiIEIgF (ORCPT ); Mon, 5 Sep 2022 04:36:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 518CA11821; Mon, 5 Sep 2022 01:34:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1CE6261183; Mon, 5 Sep 2022 08:34:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B817C43470; Mon, 5 Sep 2022 08:34:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662366847; bh=MFwr+ylrLqHsUdJos34a0n+CwOKCUfeTFHhIzjgR+eQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=j36VktyFiKHbg5ZEF7eYwQw14//bO1WbHu8aKGzTeWRY2j1Zt0QCjLlOkiP9s+DYN 56x38j43KsQwIm5I5734SyOvrRGvbdcy3709mYXgngkHE0GznBxnPOO0Pb6I5QV6gL k6eraIABCQjLDq4W3clDn29nde1Lcb5JehshdjtMlSukBy6CUtdsHopsJ+df1pzB0S leqQ1MkQ9MSzmQ82nHEidJ5l5tKuPVJxKfw6SCnFA3V77X4kTg5YTUM2IE3aMAyVb1 pzDYNpFf9Ar+yJ++X+4jR5k1kJkl1AdRkUNRq7N+0lV4qBpkoOHIBMNsGcarMxIIq4 1ZSsrLC67d8CA== Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-1274ec87ad5so5011351fac.0; Mon, 05 Sep 2022 01:34:07 -0700 (PDT) X-Gm-Message-State: ACgBeo3WP6pGCQK+AHttfilcGZBtW5QTsobY87WtXZGDXDDXbM9bHXOU sb76jl0Yfrm7A7NTwKRuF2LYWkSayuZlvn6nYNM= X-Received: by 2002:a05:6870:7092:b0:11e:ff3a:d984 with SMTP id v18-20020a056870709200b0011eff3ad984mr8071019oae.19.1662366846586; Mon, 05 Sep 2022 01:34:06 -0700 (PDT) MIME-Version: 1.0 References: <20220831175920.2806-1-jszhang@kernel.org> <20220831175920.2806-5-jszhang@kernel.org> In-Reply-To: From: Guo Ren Date: Mon, 5 Sep 2022 16:33:54 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 4/5] riscv: add lazy preempt support To: Sebastian Andrzej Siewior Cc: Jisheng Zhang , Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Atish Patra , Thomas Gleixner , Steven Rostedt , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Mon, Sep 5, 2022 at 2:34 PM Sebastian Andrzej Siewior wrote: > > On 2022-09-04 23:16:12 [+0800], Guo Ren wrote: > > > diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S > > > index b9eda3fcbd6d..595100a4c2c7 100644 > > > --- a/arch/riscv/kernel/entry.S > > > +++ b/arch/riscv/kernel/entry.S > > > @@ -361,9 +361,14 @@ restore_all: > > > resume_kernel: > > > REG_L s0, TASK_TI_PREEMPT_COUNT(tp) > > > bnez s0, restore_all > > > - REG_L s0, TASK_TI_FLAGS(tp) > > > - andi s0, s0, _TIF_NEED_RESCHED > > > + REG_L s1, TASK_TI_FLAGS(tp) > > > + andi s0, s1, _TIF_NEED_RESCHED > > > + bnez s0, 1f > > > + REG_L s0, TASK_TI_PREEMPT_LAZY_COUNT(tp) > > > + bnez s0, restore_all > > > + andi s0, s1, _TIF_NEED_RESCHED_LAZY > > Can you tell me, who increased/decreased the PREEMPT_LAZY_COUNT? And > > who set NEED_RESCHED_LAZY? > > There is "generic" code in the PREEMPT_RT patch doing that. The counter > is incremented/ decremented via preempt_lazy_enable()/disable() and one > of the user is migrate_disable()/enable(). > Basically if a task is task_is_realtime() then NEED_RESCHED is set for > the wakeup. For the remaining states (SCHED_OTHER, =E2=80=A6) NEED_RESCHE= D_LAZY > is set for the wakeup. This can be delayed if the task is in a "preempt > disable lazy" section (similar to a preempt_disable() section) but a > task_is_realtime() can still be scheduled if needed. Okay, It should be [PATCH RT]. RISC-V would also move to GENERIC_ENTRY [1], so above assembly code would be replaced by generic one, right? [1]: https://lore.kernel.org/linux-riscv/20220904072637.8619-3-guoren@kerne= l.org/T/#u > See details at > https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel= .git/plain/patches/sched__Add_support_for_lazy_preemption.patch?h=3Dlinux-6= .0.y-rt-patches > > Sebastian --=20 Best Regards Guo Ren