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=-4.0 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 47AD1C4708F for ; Tue, 1 Jun 2021 17:41:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 274C4610CB for ; Tue, 1 Jun 2021 17:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234615AbhFARnf (ORCPT ); Tue, 1 Jun 2021 13:43:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:33732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233397AbhFARne (ORCPT ); Tue, 1 Jun 2021 13:43:34 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (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 95D58610C9; Tue, 1 Jun 2021 17:41:52 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lo8Ok-004s0J-G6; Tue, 01 Jun 2021 18:41:50 +0100 Date: Tue, 01 Jun 2021 18:41:49 +0100 Message-ID: <87fsy11nz6.wl-maz@kernel.org> From: Marc Zyngier To: Quentin Perret Cc: will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kernel-team@android.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/7] KVM: arm64: Remove list_head from hyp_page In-Reply-To: References: <20210527125134.2116404-1-qperret@google.com> <20210527125134.2116404-4-qperret@google.com> <87k0nd1wgx.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: qperret@google.com, will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kernel-team@android.com, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 01 Jun 2021 16:48:06 +0100, Quentin Perret wrote: > > On Tuesday 01 Jun 2021 at 15:38:22 (+0100), Marc Zyngier wrote: > > On Thu, 27 May 2021 13:51:30 +0100, > > Quentin Perret wrote: > > > +/* > > > + * Pages that are available for allocation are tracked in free-lists, so we use > > > + * the pages themselves to store the list nodes to avoid wasting space. As the > > > + * allocator always returns zeroed pages (which are zeroed on the hyp_put_page() > > > + * path to optimize allocation speed), we also need to clean-up the list node in > > > + * each page when we take it out of the list. > > > + */ > > > +static inline void page_remove_from_list(struct hyp_page *p) > > > +{ > > > + struct list_head *node = (struct list_head *)hyp_page_to_virt(p); > > > > Nit: How about changing hyp_page_to_virt() so that it returns a > > convenient 'void *', and get rid of the ugly casts? > > It should already return void *, but I kind of liked the explicit cast > here for documentation purpose. We're turning a 'random' piece of unused > memory into a typed object, so that felt like a useful annotation. Happy > to get rid of it though. My expectations were that using hyp_page_to_virt() already serves as a pretty big warning that we're doing something unusual. I guess that if we want to be really careful about those, we should then be consistent and make it return a uintptr_t (or unsigned long) instead, actively making use of the cast, consistently, everywhere. Thanks, M. -- Without deviation from the norm, progress is not possible. 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=-4.0 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 5B9A0C47080 for ; Tue, 1 Jun 2021 17:41:58 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id BEF63613CE for ; Tue, 1 Jun 2021 17:41:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEF63613CE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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 4548440191; Tue, 1 Jun 2021 13:41:57 -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 aNX1H5J6EnCG; Tue, 1 Jun 2021 13:41:56 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 1082940413; Tue, 1 Jun 2021 13:41:56 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id A2B1D40291 for ; Tue, 1 Jun 2021 13:41:54 -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 Z5BY3QpmvInp for ; Tue, 1 Jun 2021 13:41:53 -0400 (EDT) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id B0E6640191 for ; Tue, 1 Jun 2021 13:41:53 -0400 (EDT) Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (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 95D58610C9; Tue, 1 Jun 2021 17:41:52 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lo8Ok-004s0J-G6; Tue, 01 Jun 2021 18:41:50 +0100 Date: Tue, 01 Jun 2021 18:41:49 +0100 Message-ID: <87fsy11nz6.wl-maz@kernel.org> From: Marc Zyngier To: Quentin Perret Subject: Re: [PATCH 3/7] KVM: arm64: Remove list_head from hyp_page In-Reply-To: References: <20210527125134.2116404-1-qperret@google.com> <20210527125134.2116404-4-qperret@google.com> <87k0nd1wgx.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: qperret@google.com, will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kernel-team@android.com, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: kernel-team@android.com, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, will@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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Tue, 01 Jun 2021 16:48:06 +0100, Quentin Perret wrote: > > On Tuesday 01 Jun 2021 at 15:38:22 (+0100), Marc Zyngier wrote: > > On Thu, 27 May 2021 13:51:30 +0100, > > Quentin Perret wrote: > > > +/* > > > + * Pages that are available for allocation are tracked in free-lists, so we use > > > + * the pages themselves to store the list nodes to avoid wasting space. As the > > > + * allocator always returns zeroed pages (which are zeroed on the hyp_put_page() > > > + * path to optimize allocation speed), we also need to clean-up the list node in > > > + * each page when we take it out of the list. > > > + */ > > > +static inline void page_remove_from_list(struct hyp_page *p) > > > +{ > > > + struct list_head *node = (struct list_head *)hyp_page_to_virt(p); > > > > Nit: How about changing hyp_page_to_virt() so that it returns a > > convenient 'void *', and get rid of the ugly casts? > > It should already return void *, but I kind of liked the explicit cast > here for documentation purpose. We're turning a 'random' piece of unused > memory into a typed object, so that felt like a useful annotation. Happy > to get rid of it though. My expectations were that using hyp_page_to_virt() already serves as a pretty big warning that we're doing something unusual. I guess that if we want to be really careful about those, we should then be consistent and make it return a uintptr_t (or unsigned long) instead, actively making use of the cast, consistently, everywhere. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ 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=-4.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 5DDD7C4708F for ; Tue, 1 Jun 2021 17:43: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 29B52610C9 for ; Tue, 1 Jun 2021 17:43:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29B52610C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=m1vp/4sxDYyo6wJcRMgK8G8rQofGI/NSCsx7K1Xicc0=; b=2MTsTk47MlXPw9 IGjjI6C2iaxH0rY6XyFJD70hynAyvnBhxnocn/rils4VGFUPiYixgcmQ4H05rqRqZAVmw/l3HnmtS neAFHLe+NCwB3Hl9UqRwD0O4SzQbCk1WqrsXwxW5ELyyqYp6RtQ9VVZEG7xpZBSBdIdHashRxHnnD ya9+/Eff+jYK9PSbCcAAVWbwZ6xvoyp/zxYudLCzxeqixbvJSzIJpohOHDD57VelFJ4KyT6VoyKLe V+Ohl3xxL3wCxnxQLrPlc0UByxqPWLz9s5WjzCFdWa9Xmiv/tJueQTiLYzG7isVzvIW91kefGsvkq rM5CDjznYtEN/b15GtDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lo8Oq-0007To-OA; Tue, 01 Jun 2021 17:41:56 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lo8Om-0007TA-Sz for linux-arm-kernel@lists.infradead.org; Tue, 01 Jun 2021 17:41:54 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (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 95D58610C9; Tue, 1 Jun 2021 17:41:52 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lo8Ok-004s0J-G6; Tue, 01 Jun 2021 18:41:50 +0100 Date: Tue, 01 Jun 2021 18:41:49 +0100 Message-ID: <87fsy11nz6.wl-maz@kernel.org> From: Marc Zyngier To: Quentin Perret Cc: will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kernel-team@android.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/7] KVM: arm64: Remove list_head from hyp_page In-Reply-To: References: <20210527125134.2116404-1-qperret@google.com> <20210527125134.2116404-4-qperret@google.com> <87k0nd1wgx.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: qperret@google.com, will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kernel-team@android.com, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210601_104152_982372_254B1E72 X-CRM114-Status: GOOD ( 25.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 01 Jun 2021 16:48:06 +0100, Quentin Perret wrote: > > On Tuesday 01 Jun 2021 at 15:38:22 (+0100), Marc Zyngier wrote: > > On Thu, 27 May 2021 13:51:30 +0100, > > Quentin Perret wrote: > > > +/* > > > + * Pages that are available for allocation are tracked in free-lists, so we use > > > + * the pages themselves to store the list nodes to avoid wasting space. As the > > > + * allocator always returns zeroed pages (which are zeroed on the hyp_put_page() > > > + * path to optimize allocation speed), we also need to clean-up the list node in > > > + * each page when we take it out of the list. > > > + */ > > > +static inline void page_remove_from_list(struct hyp_page *p) > > > +{ > > > + struct list_head *node = (struct list_head *)hyp_page_to_virt(p); > > > > Nit: How about changing hyp_page_to_virt() so that it returns a > > convenient 'void *', and get rid of the ugly casts? > > It should already return void *, but I kind of liked the explicit cast > here for documentation purpose. We're turning a 'random' piece of unused > memory into a typed object, so that felt like a useful annotation. Happy > to get rid of it though. My expectations were that using hyp_page_to_virt() already serves as a pretty big warning that we're doing something unusual. I guess that if we want to be really careful about those, we should then be consistent and make it return a uintptr_t (or unsigned long) instead, actively making use of the cast, consistently, everywhere. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel