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.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 DC711ECE58C for ; Fri, 11 Oct 2019 10:39:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C04922084C for ; Fri, 11 Oct 2019 10:39:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727717AbfJKKjE (ORCPT ); Fri, 11 Oct 2019 06:39:04 -0400 Received: from foss.arm.com ([217.140.110.172]:56060 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726290AbfJKKjD (ORCPT ); Fri, 11 Oct 2019 06:39:03 -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 4536F28; Fri, 11 Oct 2019 03:39:03 -0700 (PDT) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E26D63F703; Fri, 11 Oct 2019 03:39:00 -0700 (PDT) Date: Fri, 11 Oct 2019 11:38:58 +0100 From: Catalin Marinas To: "Justin He (Arm Technology China)" Cc: Will Deacon , Mark Rutland , James Morse , Marc Zyngier , Matthew Wilcox , "Kirill A. Shutemov" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , Suzuki Poulose , Borislav Petkov , "H. Peter Anvin" , "x86@kernel.org" , Thomas Gleixner , Andrew Morton , "hejianet@gmail.com" , "Kaly Xin (Arm Technology China)" , nd Subject: Re: [PATCH v11 1/4] arm64: cpufeature: introduce helper cpu_has_hw_af() Message-ID: <20191011103857.GB54842@arrakis.emea.arm.com> References: <20191009084246.123354-1-justin.he@arm.com> <20191009084246.123354-2-justin.he@arm.com> <20191010164312.GB40923@arrakis.emea.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Fri, Oct 11, 2019 at 01:16:36AM +0000, Justin He (Arm Technology China) wrote: > From: Catalin Marinas > > On Wed, Oct 09, 2019 at 04:42:43PM +0800, Jia He wrote: > > > + u64 mmfr1 = read_cpuid(ID_AA64MMFR1_EL1); > > > + > > > + return !!cpuid_feature_extract_unsigned_field(mmfr1, > > > + > > ID_AA64MMFR1_HADBS_SHIFT); > > > > No need for !!, the return type is a bool already. > > But cpuid_feature_extract_unsigned_field has the return type "unsigned int" [1] > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/include/asm/cpufeature.h#n444 And the C language gives you the automatic conversion from unsigned int to bool without the need for !!. The reason we use !! in some places is for converting long to int (not bool) and losing the top 32-bit. See commit 84fe6826c28f ("arm64: mm: Add double logical invert to pte accessors") for an explanation. -- Catalin 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.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 18406ECE58E for ; Fri, 11 Oct 2019 10:39:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D74A82089F for ; Fri, 11 Oct 2019 10:39:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D74A82089F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6E09B8E0005; Fri, 11 Oct 2019 06:39:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69B568E0001; Fri, 11 Oct 2019 06:39:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 580598E0005; Fri, 11 Oct 2019 06:39:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 3956C8E0001 for ; Fri, 11 Oct 2019 06:39:05 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id CAF5245BA for ; Fri, 11 Oct 2019 10:39:04 +0000 (UTC) X-FDA: 76031156208.11.bell62_3218cf0658825 X-HE-Tag: bell62_3218cf0658825 X-Filterd-Recvd-Size: 3054 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Oct 2019 10:39:04 +0000 (UTC) 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 4536F28; Fri, 11 Oct 2019 03:39:03 -0700 (PDT) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E26D63F703; Fri, 11 Oct 2019 03:39:00 -0700 (PDT) Date: Fri, 11 Oct 2019 11:38:58 +0100 From: Catalin Marinas To: "Justin He (Arm Technology China)" Cc: Will Deacon , Mark Rutland , James Morse , Marc Zyngier , Matthew Wilcox , "Kirill A. Shutemov" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , Suzuki Poulose , Borislav Petkov , "H. Peter Anvin" , "x86@kernel.org" , Thomas Gleixner , Andrew Morton , "hejianet@gmail.com" , "Kaly Xin (Arm Technology China)" , nd Subject: Re: [PATCH v11 1/4] arm64: cpufeature: introduce helper cpu_has_hw_af() Message-ID: <20191011103857.GB54842@arrakis.emea.arm.com> References: <20191009084246.123354-1-justin.he@arm.com> <20191009084246.123354-2-justin.he@arm.com> <20191010164312.GB40923@arrakis.emea.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Oct 11, 2019 at 01:16:36AM +0000, Justin He (Arm Technology China) wrote: > From: Catalin Marinas > > On Wed, Oct 09, 2019 at 04:42:43PM +0800, Jia He wrote: > > > + u64 mmfr1 = read_cpuid(ID_AA64MMFR1_EL1); > > > + > > > + return !!cpuid_feature_extract_unsigned_field(mmfr1, > > > + > > ID_AA64MMFR1_HADBS_SHIFT); > > > > No need for !!, the return type is a bool already. > > But cpuid_feature_extract_unsigned_field has the return type "unsigned int" [1] > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/include/asm/cpufeature.h#n444 And the C language gives you the automatic conversion from unsigned int to bool without the need for !!. The reason we use !! in some places is for converting long to int (not bool) and losing the top 32-bit. See commit 84fe6826c28f ("arm64: mm: Add double logical invert to pte accessors") for an explanation. -- Catalin 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.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 72303C47404 for ; Fri, 11 Oct 2019 10:39:15 +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 37C3F2084C for ; Fri, 11 Oct 2019 10:39:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uzGmsfRh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37C3F2084C 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-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YPFdMxa8+hZsPPkY17JC4ngKdjGagSU1mlbZBy6ZpgA=; b=uzGmsfRhzuOjuk vO3PKFJwX+2k7SkMnIL25rVVWqrU0Ca1Q+fJ2+5+Jb9nxgIOAALQZT4L8riuv7sGKcnuFhM98aoeA j4Ajfd9eM6LY6VGtjBFNNit/p0VEZlokzbX0HXXGAkDvS/dxWEwMSj4rcz5BCySZlbJzCHQEbNaV7 mRhwZTFWSHyBs53BwpEp4r2KYobD9H7muKcFVT6G/Pu4IDljZbnCwMvhIkISc5a1ussvrhQG95o1V 3jxaezbTEgHqiChZOVIY2AukEtq0jQC5Iu/S3ae5Nkj8ZV44YXMmWYQAxYv0aV6ZMpaG3ru4pDMjI 4Y/WK8yQ2vncn+LPOBFw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iIsKB-0005Bo-Ro; Fri, 11 Oct 2019 10:39:07 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iIsK7-0005B8-TW for linux-arm-kernel@lists.infradead.org; Fri, 11 Oct 2019 10:39:05 +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 4536F28; Fri, 11 Oct 2019 03:39:03 -0700 (PDT) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E26D63F703; Fri, 11 Oct 2019 03:39:00 -0700 (PDT) Date: Fri, 11 Oct 2019 11:38:58 +0100 From: Catalin Marinas To: "Justin He (Arm Technology China)" Subject: Re: [PATCH v11 1/4] arm64: cpufeature: introduce helper cpu_has_hw_af() Message-ID: <20191011103857.GB54842@arrakis.emea.arm.com> References: <20191009084246.123354-1-justin.he@arm.com> <20191009084246.123354-2-justin.he@arm.com> <20191010164312.GB40923@arrakis.emea.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191011_033903_999642_7722980B X-CRM114-Status: GOOD ( 12.37 ) 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: Mark Rutland , "Kaly Xin \(Arm Technology China\)" , Suzuki Poulose , Marc Zyngier , "x86@kernel.org" , "hejianet@gmail.com" , "linux-kernel@vger.kernel.org" , Matthew Wilcox , "linux-mm@kvack.org" , James Morse , "linux-arm-kernel@lists.infradead.org" , "H. Peter Anvin" , Borislav Petkov , Thomas Gleixner , nd , Will Deacon , Andrew Morton , "Kirill A. Shutemov" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Oct 11, 2019 at 01:16:36AM +0000, Justin He (Arm Technology China) wrote: > From: Catalin Marinas > > On Wed, Oct 09, 2019 at 04:42:43PM +0800, Jia He wrote: > > > + u64 mmfr1 = read_cpuid(ID_AA64MMFR1_EL1); > > > + > > > + return !!cpuid_feature_extract_unsigned_field(mmfr1, > > > + > > ID_AA64MMFR1_HADBS_SHIFT); > > > > No need for !!, the return type is a bool already. > > But cpuid_feature_extract_unsigned_field has the return type "unsigned int" [1] > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/include/asm/cpufeature.h#n444 And the C language gives you the automatic conversion from unsigned int to bool without the need for !!. The reason we use !! in some places is for converting long to int (not bool) and losing the top 32-bit. See commit 84fe6826c28f ("arm64: mm: Add double logical invert to pte accessors") for an explanation. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel