Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9837537pxu; Tue, 29 Dec 2020 06:32:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0+PJcMQSMk2bQdN7KY+fDKU3fTOvPQBGIC7prUA5psKElGCh6IFCwsZFFcP5k8NXAGuEC X-Received: by 2002:a17:906:605:: with SMTP id s5mr45943960ejb.280.1609252375173; Tue, 29 Dec 2020 06:32:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609252375; cv=none; d=google.com; s=arc-20160816; b=HwcTtkiscZNY7pMVxrmyCyZhfigcA4+CY/GBxoo7dZDxC62zKw6NdiklSUAWrBg+ok PyDWMcta/F56kV2/LV9WFy1S7Hv1aOCo7l3ryQM7jctzlX/go0mf4wuG17RwnfAA1d2j 1Y83ELK5retQyDu2706NWFDoyOfD8CT5FDtCo0aFeFXMNnjqvZp8VHALtyXcSt4wYq3k Rx7e+imaBbmu4AeNVGifEbmIeOAfMtvYPVgg3XSs0nuZY93L9ikl3y7Zlp5yAiKjtuF8 gA+LRPJ8Lfbf2WbA4DHyzWosNSEFi4gmVDWgEuhC+u7JJiA5+8HwfBxgQiwzkGxFew+C /3Zw== 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:dkim-signature; bh=DSqSriibiKrwyu5CY6r+24o6S+KB/xUBH/8usQPex5I=; b=MTOppYjatsXhB1PaLSxC/aRNve6Z2aZQIZM6PnyIe8YSWN3x/SDahXsC35PDJxM6gK uCDevi1u0Mn/OWisyF1Uooa56r9Z1Gde4wfbxBSZw8G+XEfd5TeiLUGhqj7bs5gEH3Fe L9aUHqOC8Fqvi67jsGjaV9WJAxGKkINCp1k1ry4jbJftH4i/xHbiBUvi6q+D5hCTmz2T 0Ins7L0Zk3X9UAEJqBttBhy7Pa7H3mzeDwyTZwXS6dlf+YNEWfcP+KStvYMY+ZpCFC6z 4sc5etNpdwEvlgFAVa2Mmn2uNdijzN1y1nXLRaIWDffeLEewyZDrNffCR/x42kk31EqD kMlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CgSwDfJN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p24si21893223edw.475.2020.12.29.06.32.31; Tue, 29 Dec 2020 06:32:55 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CgSwDfJN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726292AbgL2Obi (ORCPT + 99 others); Tue, 29 Dec 2020 09:31:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:57010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbgL2Obh (ORCPT ); Tue, 29 Dec 2020 09:31:37 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A6D6E20825; Tue, 29 Dec 2020 14:30:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609252257; bh=0/Qq83f1tC/D+PQkSdueffqo+nc97r3irtoltp2NR1c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CgSwDfJNFbHSJZT0FF7f7bn8YZJjiPdsxpJw9CEfEPK1mM5HlJz0utbWU1JdtnmPV Sm9mRgIYKotUT3Z2CpQbONynYl6YJ11PWBxpBbQ299WHz33mIOSs5S86Or7BO1KW7O LzxGUGl9p0Z30dTnowVmZi5vxak/0t811uwilGiUFawOfUbNSLAz0JruZ26Z1ip1M4 w3OoPgn/GfcHVF/B3BAIxgRnANM8M4erKbSGtFaskEgjhq8WHKkQogyBvv7KS8aVBl gmee0dKWAPRwVo3c2OaM00Ph+g9SN+OVJFAFhrnND3OlO88SbPz007eeQgyA+Q0V+H vFaLJaxeVTYgQ== Date: Tue, 29 Dec 2020 15:30:54 +0100 From: Frederic Weisbecker To: Qais Yousef 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: <20201229143054.GC21613@lothringen> References: <20201202115732.27827-1-frederic@kernel.org> <20201202115732.27827-5-frederic@kernel.org> <20201228021529.2dlioupobocjcqzk@e107158-lin> <20201229134146.GA21613@lothringen> <20201229141231.c2ppmjucxxbz5j5h@e107158-lin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201229141231.c2ppmjucxxbz5j5h@e107158-lin> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > Thanks > > -- > Qais Yousef