From mboxrd@z Thu Jan 1 00:00:00 1970 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=-7.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 221BCC43465 for ; Mon, 21 Sep 2020 13:43:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C85D320C09 for ; Mon, 21 Sep 2020 13:43:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600695812; bh=DmCZ7P6LNdCNVX2iURc2Tv+RTbArR0Kg1mI/ej12EbE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=Iaq889iHB1HKrPDHRYDiAO91ZVzqRK0xWYVLAxJPmCnAQwQnuc9MevuYOsTX72CrR UgCpQlREqVnc+RB7UTtVsGxW2ADP7uHelKIUh89RZppg6DH+Vof86e2MlMIc8FS8MH O5oSD/q81ocP31GwliZzOKBUbTIWRlHkk/u6hjFc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727332AbgIUNnb (ORCPT ); Mon, 21 Sep 2020 09:43:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:56236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726471AbgIUNna (ORCPT ); Mon, 21 Sep 2020 09:43:30 -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 D10B52084C; Mon, 21 Sep 2020 13:43:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600695810; bh=DmCZ7P6LNdCNVX2iURc2Tv+RTbArR0Kg1mI/ej12EbE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eNUZiyd9+5I4cLqEMKfuSXtwPRVFP3NRk7NB0oqya/i5QIDgYnbqfsN9qWw0VpSiO J3wuGwe/sY9cVi/OknDUnRC74FuQf99iOQpTLGIF/MyBKc3G4nnCEX9sM2xKK/PSuf dID2QWoDSef6LQt4+jkZjo4oEeIB/T/U85CZd3VM= Date: Mon, 21 Sep 2020 14:43:25 +0100 From: Will Deacon To: John Garry Cc: robin.murphy@arm.com, joro@8bytes.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, maz@kernel.org, linuxarm@huawei.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 0/2] iommu/arm-smmu-v3: Improve cmdq lock efficiency Message-ID: <20200921134324.GK2139@willie-the-truck> References: <1598018062-175608-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1598018062-175608-1-git-send-email-john.garry@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 21, 2020 at 09:54:20PM +0800, John Garry wrote: > As mentioned in [0], the CPU may consume many cycles processing > arm_smmu_cmdq_issue_cmdlist(). One issue we find is the cmpxchg() loop to > get space on the queue takes a lot of time once we start getting many > CPUs contending - from experiment, for 64 CPUs contending the cmdq, > success rate is ~ 1 in 12, which is poor, but not totally awful. > > This series removes that cmpxchg() and replaces with an atomic_add, > same as how the actual cmdq deals with maintaining the prod pointer. I'm still not a fan of this. Could you try to adapt the hacks I sent before, please? I know they weren't quite right (I have no hardware to test on), but the basic idea is to fall back to a spinlock if the cmpxchg() fails. The queueing in the spinlock implementation should avoid the contention. Thanks, Will