Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9897368pxu; Tue, 29 Dec 2020 08:00:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzoKwh41n6KuYdtkA9JBU0mnqD6cWpNWz4AcBZQ6clZBJyFrI7F7z21KuEOGFEdKaGLAA7 X-Received: by 2002:a17:906:4705:: with SMTP id y5mr45710537ejq.112.1609257632140; Tue, 29 Dec 2020 08:00:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609257632; cv=none; d=google.com; s=arc-20160816; b=ojNVUuiuzYL9m+KfL7VR3Hpjx/CthtGQr35ioe2fwMFEJApKXLueusOYB4Z/Lkxpgj MUTk9odWXCjz1pthfA5IfZaNKblVN1ePYdwd8kODqAREg2UB3ehH2/GA4Dxz3rp3cBSy XJz169Nqakc4hBGyQu+JvETohv4+IFHRz/UaKlNKn6L5nla4K/IvqEL4D0HxCBrATMc/ P5/4bZvYfTuHKzaZ26kXCjMMeJv4DsXNO6eRcgRIFFhbZdtI0j9wOtS+HC3kzG16iIfe uysEglVR8Nsrx8Z0XBFrMAJD1NL91HwTEuknZDaOo2y3VURQZXArAKaRgXK5qJdsidjs F5Ug== 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:date; bh=LhrovgApMrJ/VFBH8H4N8Ek01hQMoMFxwP7JAum99ak=; b=arW2HZs4X10zwmQm1ch+4lKgztdT9nb0gAVy82r8LeSjwvNFtGQer6251o3W9ZYd+t SPmb6w5orIkb/8eSxirV6s0QeHvtsvSrg98ZSRIfaEJcIhRrTB3M1eg5tWzYdtuAoN6f 9EJt0OjcccLys7WC+jePzlGLx8QH84Y+KJ8cK9ETZm4C6sg6Bp2cTkUbJiCJapnTpbFC i8PR+HI3GXTy0jQ3aubY9MhPnct+mrqyXs2Y+CrzNJZr2H12fZxMh5qeCrMgtI/FNVXy PteyD7aILZ5Ino2MGwMBSTHz9OJ3Ukiw2+6BBQ5HYdjdVbTFaMEbyklJj2KwzciFBESB UbmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k20si11831125edo.493.2020.12.29.08.00.09; Tue, 29 Dec 2020 08:00:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726292AbgL2P7m (ORCPT + 99 others); Tue, 29 Dec 2020 10:59:42 -0500 Received: from foss.arm.com ([217.140.110.172]:41244 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbgL2P7m (ORCPT ); Tue, 29 Dec 2020 10:59:42 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D2FD830E; Tue, 29 Dec 2020 07:58:56 -0800 (PST) Received: from e107158-lin (e107158-lin.cambridge.arm.com [10.1.194.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4DD4B3F6CF; Tue, 29 Dec 2020 07:58:55 -0800 (PST) Date: Tue, 29 Dec 2020 15:58:52 +0000 From: Qais Yousef To: Frederic Weisbecker Cc: Thomas Gleixner , Peter Zijlstra , LKML , Tony Luck , Vasily Gorbik , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Christian Borntraeger , Fenghua Yu , Heiko Carstens Subject: Re: [PATCH 4/5] irqtime: Move irqtime entry accounting after irq offset incrementation Message-ID: <20201229155852.paudsonz6m66x2nz@e107158-lin> References: <20201202115732.27827-1-frederic@kernel.org> <20201202115732.27827-5-frederic@kernel.org> <20201228021529.2dlioupobocjcqzk@e107158-lin> <20201229134146.GA21613@lothringen> <20201229141231.c2ppmjucxxbz5j5h@e107158-lin> <20201229143054.GC21613@lothringen> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201229143054.GC21613@lothringen> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/29/20 15:30, Frederic Weisbecker wrote: > On Tue, Dec 29, 2020 at 02:12:31PM +0000, Qais Yousef wrote: > > On 12/29/20 14:41, Frederic Weisbecker wrote: > > > > > -void vtime_account_irq(struct task_struct *tsk) > > > > > +void vtime_account_irq(struct task_struct *tsk, unsigned int offset) > > > > > { > > > > > - if (hardirq_count()) { > > > > > + unsigned int pc = preempt_count() - offset; > > > > > + > > > > > + if (pc & HARDIRQ_OFFSET) { > > > > > > > > Shouldn't this be HARDIRQ_MASK like above? > > > > > > In the rare cases of nested hardirqs happening with broken drivers, Only the outer hardirq > > > does matter. All the time spent in the inner hardirqs is included in the outer > > > one. > > > > Ah I see. The original code was doing hardirq_count(), which apparently wasn't > > right either. > > > > Shouldn't it be pc == HARDIRQ_OFFSET then? All odd nest counts will trigger > > this otherwise, and IIUC we want this to trigger once on first entry only. > > Right but we must also handle hardirqs interrupting either preempt disabled sections > or softirq servicing/disabled section. > > 3 stacking hardirqs should be rare enough that we don't really care. In the > worst case we are going to account the third IRQ seperately. Not a correctness > issue, just a rare unoptimized case. I admit I need to wrap my head around some more details to fully comprehend that, but that's my own confusion to clear out :-) Thanks for your answer. Cheers -- Qais Yousef