Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2730603rwb; Sun, 4 Sep 2022 23:54:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR62V6APirZBUjuXytZMen+/O49alI2bfi9ZZpH8gaahp0hJ07MrfVSdOHgsyu5yaS7oWu+z X-Received: by 2002:a17:902:b697:b0:172:65f9:d681 with SMTP id c23-20020a170902b69700b0017265f9d681mr46946400pls.137.1662360841884; Sun, 04 Sep 2022 23:54:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662360841; cv=none; d=google.com; s=arc-20160816; b=mByHa2eWCXmfXkydUhxWWTUm7Xgxx+6maVdE0KTQnGjq5pr+N4PbB9/l/3jGV5BMiL i4IJTJplQeDPiE/9/9jkncDIYaEJekvBt1F6s6oNgbwgRf1QRil7aiLAq7LEtAI6I/IN OclIUfnrzpIw8vIrcI106FNutl0652Z4ylBm1Dtt4ZTWnlVu+eoGX6m9K4wFRKIULlfx e917T5lZYry3htea2+XyJ9bFJ5fU7ErZlNFH6ZGXJf/VvyJDvdVMjIo6fblcLnAPXUGw OrlHptWm+fF+uGgUuBx+uSnKrxH+Ytuc8WX3hNZcahrCm4DZe5R2dO+6tH6agA7rXLuA ZG/g== 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:dkim-signature:dkim-signature:date; bh=ymTw5XBMYgKVIeJh9aYTiMBe+I7d6R0sABW/gVPUNZY=; b=nfB+9TVOwdxap1b9LvnU0axevfk3ImORykJ2ron9dl4v3VBMfneAq2IgE+EsoIKJLt FX17cQWytdducG2k8wxv0uSJ/by+BjNP/MLQrq9zcFqBE/lMa7Tux58w8NYAoo5LA2X6 yajAZYiXFH+ByAnWX6POc+JDzLaXmnCmQQ7sDN0w6cpm8S0tf2u6bCILmFy4scs9oc3Z kQBr7qw+gVDybS/Ik04AVBQC8K78vZpxHteCiBqw8ib+KT1alNzhpY6V/GjG868vrqYm Nhx3c8eN7eA6VULnCnPUeLPLvTaGIhkjCciu8krD5CfCSUgoV1mxMz8KzvY0F2YSxZVB IJwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1JYwlslT; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i1-20020a17090a058100b001fda01de650si9637745pji.122.2022.09.04.23.53.49; Sun, 04 Sep 2022 23:54:01 -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=@linutronix.de header.s=2020 header.b=1JYwlslT; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236948AbiIEGfz (ORCPT + 99 others); Mon, 5 Sep 2022 02:35:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236559AbiIEGfc (ORCPT ); Mon, 5 Sep 2022 02:35:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07A22175AC; Sun, 4 Sep 2022 23:34:51 -0700 (PDT) Date: Mon, 5 Sep 2022 08:34:47 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1662359689; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ymTw5XBMYgKVIeJh9aYTiMBe+I7d6R0sABW/gVPUNZY=; b=1JYwlslTPGKZVLWAgIQLOvrV5cS2f8XDBRsTxuEp4kuwx1izZCcslOZ3ouAyPBRPJAUipU 8hkT40r2lrqxV36uNBcdu6GN3k+gRKy3A20Vfb6aDcTfykHqDETNrXxGNLsp1dkOwui7sv B+Upmccg8S3ynJn9P9xaZfzpC9gEedcnDR9EsaLT2GYIdQTtWEIxHR3w3lPPTqO+4IlQBe utoikxUCGJsQJnsm62aE3NQbaK+DGcg2mpPDh5mNL7Uj7HWjtLCUY/JHwTqdpUpvovO455 AFcOc0s6k6weRuTpTXJkwfVeuKT6biMkgP3aRmN95R6tmvP3EE3MLdZx5GFb/A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1662359689; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ymTw5XBMYgKVIeJh9aYTiMBe+I7d6R0sABW/gVPUNZY=; b=c1FZvonWTQ4c1SjsgaR7+xk9CjbBSZWzEPYyI813LvRBHJzV4x3X5FgF3oZajvj+l/9uTs x7xDwB890V4ZC4DA== From: Sebastian Andrzej Siewior To: Guo Ren 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 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: quoted-printable In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 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_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. See details at https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git/plai= n/patches/sched__Add_support_for_lazy_preemption.patch?h=3Dlinux-6.0.y-rt-p= atches Sebastian