Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3105834rwb; Mon, 5 Sep 2022 06:36:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR6g61HKndK1pCvuYoq7ikgzPjbLMIN8a2/wqWgTK0czshfbdD44A6uusmAndcbsx55KRAO1 X-Received: by 2002:a17:907:72c3:b0:73f:55cd:174f with SMTP id du3-20020a17090772c300b0073f55cd174fmr30878745ejc.90.1662384979556; Mon, 05 Sep 2022 06:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662384979; cv=none; d=google.com; s=arc-20160816; b=xHqHfknQlRvwd1ElJCy3Kvwm0UAVPdqXqej+NnYPKh4eNFT0EsSQrlIJ8IItZklQPT Jdil2SUbEui1y11NBD+w357jdLE6ta+jKprn/WWLemrZ9ti2cnvBDPFACQIN0XEfXQSv 8vlkxtqjOMYdl8j5ZxalTQ8p5tylT5kBHEAxTE/04L6yADYWDBRRWYvfooxjB8eY8Hl2 lSPMsxFqKcvCm+cvEE8P8cX0Cbib372ry3oGzdd5Z94HThCZBjlL48s2ykrNlifN9svd qWvgY+chGhOo/NxGFF2WkZ+WO61c2+WvLiu527Wh8wIlOt/J3ixGCFeLdsTQzoivW5vx Artw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/Fb6qAPo+ABGbsqwCTtye8XpWD9y/L3upb+3j6p6Opk=; b=XHCyrqeM4AQ/NRci7K7izxYEYwQq+t2ZnNa8dfqxamFK0LskIdaVNfvwMlNQY2aWR0 MYPmW1KSLFs6K1uy80FTSRbthfosy9WbzIM3kmQSgNizkREAFyKCb4MmTYJV3c3NQrYk 68/76LnmCSxUygEonwDgB8bsdW26WvwXDsfPVZd4bYk9a3glWbqD/mwLQdD1+lselC7x xG4xR3JHsarxo30vRI2/6kBi0IDjovcKyUEAIPXECHZ5pO4luf16AJQ4oSKapqsey55a BV8KYIYmLb+zpFOnBlAcliaIdIqkHhcJAOYvxVSUn4R2MDMvuOXlhcTsm0yXGogogU7B D1HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TaU9odUX; 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 hr31-20020a1709073f9f00b0072b9d9aab6csi8725387ejc.284.2022.09.05.06.35.50; Mon, 05 Sep 2022 06:36:19 -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=TaU9odUX; 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 S236210AbiIENHb (ORCPT + 99 others); Mon, 5 Sep 2022 09:07:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbiIENH2 (ORCPT ); Mon, 5 Sep 2022 09:07:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DEB01FCFC; Mon, 5 Sep 2022 06:07:27 -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 ams.source.kernel.org (Postfix) with ESMTPS id 32C90B81141; Mon, 5 Sep 2022 13:07:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A6BBC433D6; Mon, 5 Sep 2022 13:07:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662383244; bh=7g8Fl87EiIp0MAGm2fwDOr/M7eySmwTBGpTA8Hg0++c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TaU9odUXlZlOd8u9PAlqDRvhOHq3qcUmnL8iqNaA4dtLhcqMyMyve+QOtg94AVHmI bvshf8Ju+nL5NnLa4jx8j99rwxheJ3d2Rg45gZyeSZ/pxLYJ/Q6yVWnJgC3fGBaMiY SnOGn1OFB5TD6B4UR9L6qFjK5GFSQLkt/vUIxMKoovZ+VrS8Dh9IMMTA3F2ZJzkBqe 6ACcQz9MMpK9iQEidp7N5y0Ow+WI9wPO4Eiw8Dr+frDwnLm6Jk27PpOtpSvItbJwtB NlkwBcQfz16+Gd9c7MFj+rcz3SjdVV7KR791+zKZeHubDrwSBBCCOvrODXToO6yP70 /Zn3E9RPQ94sA== Date: Mon, 5 Sep 2022 20:58:03 +0800 From: Jisheng Zhang To: Guo Ren Cc: Sebastian Andrzej Siewior , 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 Subject: Re: [PATCH v2 4/5] riscv: add lazy preempt support Message-ID: References: <20220831175920.2806-1-jszhang@kernel.org> <20220831175920.2806-5-jszhang@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 05, 2022 at 04:33:54PM +0800, Guo Ren wrote: > 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, …) NEED_RESCHED_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 As said in the cover letter, this patch is expected to reviewed and maintained in RT tree. If your GENERIC_ENTRY patches are merged, I will send an updated patch. > [1], so above assembly code would be replaced by generic one, right? > > [1]: https://lore.kernel.org/linux-riscv/20220904072637.8619-3-guoren@kernel.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=linux-6.0.y-rt-patches > > > > > > Sebastian > > > > -- > Best Regards > Guo Ren