Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by archive.lwn.net (Postfix) with ESMTPS id 027607D910 for ; Wed, 11 Mar 2020 15:39:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WLF8cXrKq8PmjwsWM4ixVmFV4M9rcp54sqfsbKIpQbI=; b=oA08GAbGhDPjlw fYKZu5+4kCcp/tycLIYiCiy27P4w4QX3G56/fgCvRWXMHxvmgHk9D069ysNL8qQoZSS6y95wF9g8L /hdDjaJkt0yV01eASRo8dxJbKKM/Kp/el0EWggSCYJ+DsB0j3PzVpIBfvtkWN9C1LBEnNgoM6SB4m huQ3kJY83EgQb+wVn/2y6iUNlVQNVLs6Unv7h8FYUb/qR9nVl6yqD6hx/qBGsx4Xz4F1OO0zNNADg O40M0JYIxPvhRgRY8BcYAKcEJhrgrggg/0M2JzcHBeDOf/V8RrfFibeqiYhMSwa9x9K5mV/7Rf+5v Xoa490aUUctWktIU0xzw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jC3SN-0002Rm-Nf; Wed, 11 Mar 2020 15:39:39 +0000 Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jC3SI-0002RI-27; Wed, 11 Mar 2020 15:39:35 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id AFB7F30066E; Wed, 11 Mar 2020 16:39:29 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 8997020225666; Wed, 11 Mar 2020 16:39:29 +0100 (CET) Date: Wed, 11 Mar 2020 16:39:29 +0100 From: Peter Zijlstra To: cl@rock-chips.com Subject: Re: [PATCH v3 1/1] kthread: do not preempt current task if it is going to call schedule() Message-ID: <20200311153929.GQ12561@hirez.programming.kicks-ass.net> References: <20200306070133.18335-1-cl@rock-chips.com> <20200306070133.18335-2-cl@rock-chips.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200306070133.18335-2-cl@rock-chips.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: juri.lelli@redhat.com, mark.rutland@arm.com, heiko@sntech.de, geert+renesas@glider.be, catalin.marinas@arm.com, bsegall@google.com, will@kernel.org, mpe@ellerman.id.au, linux@armlinux.org.uk, dietmar.eggemann@arm.com, ben.dooks@codethink.co.uk, mgorman@suse.de, huangtao@rock-chips.com, keescook@chromium.org, anshuman.khandual@arm.com, rostedt@goodmis.org, tglx@linutronix.de, surenb@google.com, mingo@redhat.com, allison@lohutok.net, linux-arm-kernel@lists.infradead.org, wad@chromium.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, luto@amacapital.net, george_davis@mentor.com, sudeep.holla@arm.com, akpm@linux-foundation.org, info@metux.net, kstewart@linuxfoundation.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+lwn-linux-arm-kernel=archive.lwn.net@lists.infradead.org Archived-At: List-Archive: On Fri, Mar 06, 2020 at 03:01:33PM +0800, cl@rock-chips.com wrote: > From: Liang Chen > > when we create a kthread with ktrhead_create_on_cpu(),the child thread > entry is ktread.c:ktrhead() which will be preempted by the parent after > call complete(done) while schedule() is not called yet,then the parent > will call wait_task_inactive(child) but the child is still on the runqueue, > so the parent will schedule_hrtimeout() for 1 jiffy,it will waste a lot of > time,especially on startup. > > parent child > ktrhead_create_on_cpu() > wait_fo_completion(&done) -----> ktread.c:ktrhead() > |----- complete(done);--wakeup and preempted by parent > kthread_bind() <------------| |-> schedule();--dequeue here > wait_task_inactive(child) | > schedule_hrtimeout(1 jiffy) -| > > So we hope the child just wakeup parent but not preempted by parent, and the > child is going to call schedule() soon,then the parent will not call > schedule_hrtimeout(1 jiffy) as the child is already dequeue. > > The same issue for ktrhead_park()&&kthread_parkme(). > This patch can save 120ms on rk312x startup with CONFIG_HZ=300. > > Signed-off-by: Liang Chen Thanks! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel