Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp649547ybi; Wed, 19 Jun 2019 05:42:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyClxn/NAHsTcfZOvZr/fjCprMJrgpp4dokRbRAoAoj5F6yz3AMHxXkqAtahm3LWdRdxhKM X-Received: by 2002:a17:90a:bb0c:: with SMTP id u12mr11182806pjr.132.1560948120012; Wed, 19 Jun 2019 05:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560948120; cv=none; d=google.com; s=arc-20160816; b=G2OiCK5BB29If9smszq9eNaWaoUMhGlqYoLeOz+c0986o+DWN77Yqmcf59a7EPFL2p K2KJS0sY9n0VGodKLZdRURgNW0cHXFwHPLynDDGaAFCBSacwJp8Lqy64naXPggXgijos enODLA3k7f7Ita2VJyxOCkQRFn52jqZMgEaofakZlVzWrEiWlbmRVE8DAPADHiKo7eYo gAX613AJJ10QAd+YzrPVNPwKSURKjinNXcB9f5maf413OFTd5Aca68oaCJ41hTTvZAqe Lb3zmsTWdLEoZj6FIqCJUO5oKA7B5sKddmeI1CzK6vyOwYwaMLzmMGh0W9woPONQyk96 sHqQ== 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; bh=81sox6NMr/hjZOxiC49aO2puJmFCkArRLiX42C+avYc=; b=nMlvbgYIL+cW//k4HurREUEGji8JvqAFTlnrWUsZAIXo+luAFYLkmgbeUiaxH5Hjjt tGej5FJnfLsudy8sw9LojTzjzwpt67+PscquRy0DCWnJtC5c9Rww8m+PSnW2Gr8xlYaa Rd7bBHJ9mv6eWMP8k+vJqW8X/9TXr6a4v187WHf2ShIWIcNDocGVthbZKK5v0VJGfcKa xFuNORkqn8UaTmfI/2J2eFCMzlCFB0r2z0yTkssxRRcr/Rc1PCqHEFWsMaXaXgI/SFtJ i1qBoEistm6bTjxcaHy+nlnh4if/hcrB5gNrxpCnOKcquYHLBVatSd7etd+AXmhVZpTf ADzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y187si3022683pgd.113.2019.06.19.05.41.44; Wed, 19 Jun 2019 05:42:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731809AbfFSMjp (ORCPT + 99 others); Wed, 19 Jun 2019 08:39:45 -0400 Received: from foss.arm.com ([217.140.110.172]:37752 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727314AbfFSMjp (ORCPT ); Wed, 19 Jun 2019 08:39:45 -0400 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 945BC360; Wed, 19 Jun 2019 05:39:44 -0700 (PDT) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 092A33F738; Wed, 19 Jun 2019 05:39:41 -0700 (PDT) Date: Wed, 19 Jun 2019 13:39:39 +0100 From: Will Deacon To: Guo Ren Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, Julien Grall , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, aou@eecs.berkeley.edu, gary@garyguo.net, Atish.Patra@wdc.com, hch@infradead.org, paul.walmsley@sifive.com, rppt@linux.ibm.com, linux-riscv@lists.infradead.org, Anup Patel , Palmer Dabbelt , suzuki.poulose@arm.com, Marc Zyngier , catalin.marinas@arm.com, julien.thierry@arm.com, christoffer.dall@arm.com, james.morse@arm.com Subject: Re: [PATCH RFC 11/14] arm64: Move the ASID allocator code in a separate file Message-ID: <20190619123939.GF7767@fuggles.cambridge.arm.com> References: <20190321163623.20219-1-julien.grall@arm.com> <20190321163623.20219-12-julien.grall@arm.com> <0dfe120b-066a-2ac8-13bc-3f5a29e2caa3@arm.com> <20190619091219.GB7767@fuggles.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1+86 (6f28e57d73f2) () Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 19, 2019 at 08:18:04PM +0800, Guo Ren wrote: > On Wed, Jun 19, 2019 at 5:12 PM Will Deacon wrote: > > This is one place where I'd actually prefer not to go down the route of > > making the code generic. Context-switching and low-level TLB management > > is deeply architecture-specific and I worry that by trying to make this > > code common, we run the real risk of introducing subtle bugs on some > > architecture every time it is changed. > "Add generic asid code" and "move arm's into generic" are two things. > We could do > first and let architecture's maintainer to choose. If I understand the proposal being discussed, it involves basing that generic ASID allocation code around the arm64 implementation which I don't necessarily think is a good starting point. > > Furthermore, the algorithm we use > > on arm64 is designed to scale to large systems using DVM and may well be > > too complex and/or sub-optimal for architectures with different system > > topologies or TLB invalidation mechanisms. > It's just a asid algorithm not very complex and there is a callback > for architecture to define their > own local hart tlb flush. Seems it has nothing with DVM or tlb > broadcast mechanism. I'm pleased that you think the algorithm is not very complex, but I'm also worried that you might not have fully understood some of its finer details. The reason I mention DVM and TLB broadcasting is because, depending on the mechanisms in your architecture relating to those, it may be strictly required that all concurrently running threads of a process have the same ASID at any given point in time, or it may be that you really don't care. If you don't care, then the arm64 allocator is over-engineered and likely inefficient for your system. If you do care, then it's worth considering whether a lock is sufficient around the allocator if you don't expect high core counts. Another possibility is that you end up using only one ASID and invalidating the local TLB on every context switch. Yet another design would be to manage per-cpu ASID pools. So rather than blindly copying the arm64 code, I suggest sitting down and designing something that fits to your architecture instead. You may end up with something that is both simpler and more efficient. Will