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=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 250DCC7618F for ; Mon, 15 Jul 2019 10:58:56 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id B833C206B8 for ; Mon, 15 Jul 2019 10:58:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B833C206B8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 242A64A4F3; Mon, 15 Jul 2019 06:58:55 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dZEYoD-eVCkl; Mon, 15 Jul 2019 06:58:53 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id D2D0D4A4F9; Mon, 15 Jul 2019 06:58:53 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 000A34A4F3 for ; Mon, 15 Jul 2019 06:58:52 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Gj3GmVTUFiPV for ; Mon, 15 Jul 2019 06:58:51 -0400 (EDT) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 7635C4A3A3 for ; Mon, 15 Jul 2019 06:58:51 -0400 (EDT) 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 E6E292B; Mon, 15 Jul 2019 03:58:50 -0700 (PDT) Received: from [10.1.196.50] (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C68BF3F59C; Mon, 15 Jul 2019 03:58:49 -0700 (PDT) Subject: Re: [RFC v2 11/14] arm64: Move the ASID allocator code in a separate file To: James Morse References: <20190620130608.17230-1-julien.grall@arm.com> <20190620130608.17230-12-julien.grall@arm.com> <3e6c6636-8522-ab4a-0183-ae0198a7a047@arm.com> From: Julien Grall Message-ID: <9e605949-4c3f-da9a-228c-25e694ced5df@arm.com> Date: Mon, 15 Jul 2019 11:58:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: <3e6c6636-8522-ab4a-0183-ae0198a7a047@arm.com> Content-Language: en-US Cc: marc.zyngier@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On 04/07/2019 15:56, James Morse wrote: > Hi Julien, Hi James, Thank you for the review. > > On 20/06/2019 14:06, Julien Grall wrote: >> We will want to re-use the ASID allocator in a separate context (e.g >> allocating VMID). So move the code in a new file. >> >> The function asid_check_context has been moved in the header as a static >> inline function because we want to avoid add a branch when checking if the >> ASID is still valid. > >> diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c >> index 3df63a28856c..b745cf356fe1 100644 >> --- a/arch/arm64/mm/context.c >> +++ b/arch/arm64/mm/context.c >> @@ -23,46 +23,21 @@ > >> -#define ASID_FIRST_VERSION(info) NUM_ASIDS(info) > >> diff --git a/arch/arm64/lib/asid.c b/arch/arm64/lib/asid.c >> new file mode 100644 >> index 000000000000..7252e4fdd5e9 >> --- /dev/null >> +++ b/arch/arm64/lib/asid.c >> @@ -0,0 +1,185 @@ > >> +#define ASID_FIRST_VERSION(info) (1UL << ((info)->bits)) > > (oops!) Good catch, I will fix it in the next version. > > >> @@ -344,7 +115,7 @@ static int asids_init(void) >> if (!asid_allocator_init(&asid_info, bits, ASID_PER_CONTEXT, >> asid_flush_cpu_ctxt)) >> panic("Unable to initialize ASID allocator for %lu ASIDs\n", >> - 1UL << bits); >> + NUM_ASIDS(&asid_info)); > > Could this go in the patch that adds NUM_ASIDS()? Actually this change is potentially wrong. This relies on asid_allocator_init() to set asid_info.bits even if the function fails. So I think it would be best to keep 1UL << bits here. Cheers, -- Julien Grall _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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=-5.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 7B7DCC76191 for ; Mon, 15 Jul 2019 10:59:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 485D22080A for ; Mon, 15 Jul 2019 10:59:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="VSTzjo9x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 485D22080A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tnNUq7+JZKuWatj8UthgEkUTe3UuW3PRzET6demYFmA=; b=VSTzjo9xTxk1FkoTWxpcIDmGG KvdtpxV7ZNlijh/+YS+JRzgnJyZRYV0ok72UzC3+M225utyumbXWTDjiRcfporH/o3o8NF963cc6r s15Yk1yJJiiJMZNfb1LvC3tmwATUMo0h0EDv63E19GZazWwKen804B6737KXWcdu4MHrEMWAeEFTk qVb+X5ataRRLa3ub70dgw15d4G4XJNqikrTYw0sidyX11makLIllwKonFGv6wKzOLyTz6fycU8TK6 bLXkQHxwU6cqjwe1IShLwbxeiaEAB8bS6OgIc8VXyHRuqXs3lEyR1cnN9TVS/wKaoLGYeiMGD11SP ifbSUDySQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hmyh6-00061F-PV; Mon, 15 Jul 2019 10:58:56 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hmyh3-0005xQ-46 for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2019 10:58:54 +0000 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 E6E292B; Mon, 15 Jul 2019 03:58:50 -0700 (PDT) Received: from [10.1.196.50] (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C68BF3F59C; Mon, 15 Jul 2019 03:58:49 -0700 (PDT) Subject: Re: [RFC v2 11/14] arm64: Move the ASID allocator code in a separate file To: James Morse References: <20190620130608.17230-1-julien.grall@arm.com> <20190620130608.17230-12-julien.grall@arm.com> <3e6c6636-8522-ab4a-0183-ae0198a7a047@arm.com> From: Julien Grall Message-ID: <9e605949-4c3f-da9a-228c-25e694ced5df@arm.com> Date: Mon, 15 Jul 2019 11:58:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: <3e6c6636-8522-ab4a-0183-ae0198a7a047@arm.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190715_035853_256728_67CF9340 X-CRM114-Status: GOOD ( 18.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: julien.thierry@arm.com, marc.zyngier@arm.com, catalin.marinas@arm.com, suzuki.poulose@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 04/07/2019 15:56, James Morse wrote: > Hi Julien, Hi James, Thank you for the review. > > On 20/06/2019 14:06, Julien Grall wrote: >> We will want to re-use the ASID allocator in a separate context (e.g >> allocating VMID). So move the code in a new file. >> >> The function asid_check_context has been moved in the header as a static >> inline function because we want to avoid add a branch when checking if the >> ASID is still valid. > >> diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c >> index 3df63a28856c..b745cf356fe1 100644 >> --- a/arch/arm64/mm/context.c >> +++ b/arch/arm64/mm/context.c >> @@ -23,46 +23,21 @@ > >> -#define ASID_FIRST_VERSION(info) NUM_ASIDS(info) > >> diff --git a/arch/arm64/lib/asid.c b/arch/arm64/lib/asid.c >> new file mode 100644 >> index 000000000000..7252e4fdd5e9 >> --- /dev/null >> +++ b/arch/arm64/lib/asid.c >> @@ -0,0 +1,185 @@ > >> +#define ASID_FIRST_VERSION(info) (1UL << ((info)->bits)) > > (oops!) Good catch, I will fix it in the next version. > > >> @@ -344,7 +115,7 @@ static int asids_init(void) >> if (!asid_allocator_init(&asid_info, bits, ASID_PER_CONTEXT, >> asid_flush_cpu_ctxt)) >> panic("Unable to initialize ASID allocator for %lu ASIDs\n", >> - 1UL << bits); >> + NUM_ASIDS(&asid_info)); > > Could this go in the patch that adds NUM_ASIDS()? Actually this change is potentially wrong. This relies on asid_allocator_init() to set asid_info.bits even if the function fails. So I think it would be best to keep 1UL << bits here. Cheers, -- Julien Grall _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 D8D21C7618F for ; Mon, 15 Jul 2019 10:58:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B628A206B8 for ; Mon, 15 Jul 2019 10:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729880AbfGOK6v (ORCPT ); Mon, 15 Jul 2019 06:58:51 -0400 Received: from foss.arm.com ([217.140.110.172]:47206 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729591AbfGOK6v (ORCPT ); Mon, 15 Jul 2019 06:58:51 -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 E6E292B; Mon, 15 Jul 2019 03:58:50 -0700 (PDT) Received: from [10.1.196.50] (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C68BF3F59C; Mon, 15 Jul 2019 03:58:49 -0700 (PDT) Subject: Re: [RFC v2 11/14] arm64: Move the ASID allocator code in a separate file To: James Morse Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com, julien.thierry@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will.deacon@arm.com References: <20190620130608.17230-1-julien.grall@arm.com> <20190620130608.17230-12-julien.grall@arm.com> <3e6c6636-8522-ab4a-0183-ae0198a7a047@arm.com> From: Julien Grall Message-ID: <9e605949-4c3f-da9a-228c-25e694ced5df@arm.com> Date: Mon, 15 Jul 2019 11:58:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: <3e6c6636-8522-ab4a-0183-ae0198a7a047@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/07/2019 15:56, James Morse wrote: > Hi Julien, Hi James, Thank you for the review. > > On 20/06/2019 14:06, Julien Grall wrote: >> We will want to re-use the ASID allocator in a separate context (e.g >> allocating VMID). So move the code in a new file. >> >> The function asid_check_context has been moved in the header as a static >> inline function because we want to avoid add a branch when checking if the >> ASID is still valid. > >> diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c >> index 3df63a28856c..b745cf356fe1 100644 >> --- a/arch/arm64/mm/context.c >> +++ b/arch/arm64/mm/context.c >> @@ -23,46 +23,21 @@ > >> -#define ASID_FIRST_VERSION(info) NUM_ASIDS(info) > >> diff --git a/arch/arm64/lib/asid.c b/arch/arm64/lib/asid.c >> new file mode 100644 >> index 000000000000..7252e4fdd5e9 >> --- /dev/null >> +++ b/arch/arm64/lib/asid.c >> @@ -0,0 +1,185 @@ > >> +#define ASID_FIRST_VERSION(info) (1UL << ((info)->bits)) > > (oops!) Good catch, I will fix it in the next version. > > >> @@ -344,7 +115,7 @@ static int asids_init(void) >> if (!asid_allocator_init(&asid_info, bits, ASID_PER_CONTEXT, >> asid_flush_cpu_ctxt)) >> panic("Unable to initialize ASID allocator for %lu ASIDs\n", >> - 1UL << bits); >> + NUM_ASIDS(&asid_info)); > > Could this go in the patch that adds NUM_ASIDS()? Actually this change is potentially wrong. This relies on asid_allocator_init() to set asid_info.bits even if the function fails. So I think it would be best to keep 1UL << bits here. Cheers, -- Julien Grall