Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3191062pxk; Mon, 7 Sep 2020 06:01:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1pcKO4UHETknGjIqBXS1urWNCuOk89lU7Lf3L6coBm+Vy8erIovC7tqtOeGSUIlndsYqd X-Received: by 2002:a17:906:cc98:: with SMTP id oq24mr19244962ejb.106.1599483697828; Mon, 07 Sep 2020 06:01:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599483697; cv=none; d=google.com; s=arc-20160816; b=aDhbnBGJ1rhN+7opVIkEvu8SFcJJpe5r1IemJpVDvMgOSvlZ3I4Hchn3xomXOG60TZ TYc3Cxc1w7fG+KWG9Qy+0vb5I8GDO45R0wJbdwpQQ2Qo3U4M5YSZoW5hN2WciQOi6qh5 kiDui1Wyj8dFDzBjZGhBXs2E6cEPcMmeOuwtHqfNNdRYbICiG8B2X65GYAOUW1Xaw7OF F8LSXKO1PnRXS5ytYIbj5qRsJj8hbfkpf2UxOcHnBYImmHfdsemgwY3GXewZ+xQFD7Ce DF3nsZzLTRoPrWFRzOF1g3HR8Dz7CQSAUKtB9m7JHoz+wh+mTKL81/r2DVS8WX96a/AB l/ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=miDxy3SRb2Tw+yuLinMyXYzStuHR25eFCmQuY/BRR+M=; b=uLmE8E+k/xEDMpvgP4pFh8yfddqrYVyRTWMbzeqNwoFzda6LqDGf8zQKLoucxX1XzD 1m26JVHceio+IEqnrLbCkTH/lhBd0aJ/HNoI/ReF1y8YnPeIfovqED25ME9zD+lB/Ilb UwcgUoF2xqc/1HCHdDTgRRPsoMXisKwauFIX8gckjiQ7j11IT0TOqvDkRrmUiEPPN15p femLgD2LGX9AZzsIN4g/+5zolyAfFstIRmQViRAJMAbtOl+fRo8kSdaucSS9gk7uLE/a OCHpWIyM/JZPrG8jHwpC9PYrzGWFD60xhWD8UUq9BKZH0R5JtDyImW+AyGvIVtnAIThB 8QOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NWfY8J1Z; 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 v23si9492479ejh.356.2020.09.07.06.01.15; Mon, 07 Sep 2020 06:01:37 -0700 (PDT) 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=default header.b=NWfY8J1Z; 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 S1729356AbgIGNAI (ORCPT + 99 others); Mon, 7 Sep 2020 09:00:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:52638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729162AbgIGM64 (ORCPT ); Mon, 7 Sep 2020 08:58:56 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4FB5821481; Mon, 7 Sep 2020 12:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599483529; bh=tTNxmJ4jcJ4aD21IqESGwfJw58XiGcHeIj4d4qcIdiM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NWfY8J1ZIMU4ZX4aYaDKe0hXhzsGwABV0tkTyeYkRZVLhpbrVwc54OY8ic1Vb/xux TIzDw1ejYj2Ue1gCnLpqxFGbmXblUZIchelxQkgS7DZvwqvL23Rc1PPICpuKhqcMzQ hVqiAEtb5AylhxDhE+f9OQYbOyXM35EHUzp3KS24= Date: Mon, 7 Sep 2020 13:58:44 +0100 From: Will Deacon To: Sebastian Andrzej Siewior Cc: peterz@infradead.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Jens Axboe , Thomas Gleixner , Catalin Marinas Subject: Re: [PATCH 1/2] sched: Bring the PF_IO_WORKER and PF_WQ_WORKER bits closer together Message-ID: <20200907125843.GC12237@willie-the-truck> References: <20200819142134.GD2674@hirez.programming.kicks-ass.net> <20200819195505.y3fxk72sotnrkczi@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200819195505.y3fxk72sotnrkczi@linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 19, 2020 at 09:55:05PM +0200, Sebastian Andrzej Siewior wrote: > The bits PF_IO_WORKER and PF_WQ_WORKER are tested together in > sched_submit_work() which is considered to be a hot path. > If the two bits cross the 8 or 16 bit boundary then most architecture > require multiple load instructions in order to create the constant > value. Also, such a value can not be encoded within the compare opcode. > > By moving the bit definition within the same block, the compiler can > create/use one immediate value. > > For some reason gcc-10 on ARM64 requires both bits to be next to each > other in order to issue "tst reg, val; bne label". Otherwise the result > is "mov reg1, val; tst reg, reg1; bne label". > > Move PF_VCPU out of the way so that PF_IO_WORKER can be next to > PF_WQ_WORKER. > > Signed-off-by: Sebastian Andrzej Siewior > --- > > Could someone from the ARM64 camp please verify if this a gcc "bug" or > opcode/arch limitation? With PF_IO_WORKER as 1 (without the PF_VCPU > swap) I get for ARM: > > | tst r2, #33 @ task_flags, > | beq .L998 @, > > however ARM64 does here: > | mov w0, 33 // tmp117, > | tst w19, w0 // task_flags, tmp117 > | bne .L453 //, > > the extra mov operation. Moving PF_IO_WORKER next to PF_WQ_WORKER as > this patch gives me: > | tst w19, 48 // task_flags, > | bne .L453 //, Moving an immediate into a register really shouldn't be a performance issue, so I don't think this is a problem. However, the reason GCC does this is because of the slightly weird way in which immediates are encoded, meaning that '33' can't be packed into the 'tst' alias. You can try to decipher the "DecodeBitMasks()" pseudocode in the Arm ARM if you're interested. Will