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.