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=-3.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 143C0C4708F for ; Wed, 2 Jun 2021 09:23:45 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 895B5613D6 for ; Wed, 2 Jun 2021 09:23:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 895B5613D6 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.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 03F26402DB; Wed, 2 Jun 2021 05:23:44 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com 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 D4sUBM0cY0HY; Wed, 2 Jun 2021 05:23:40 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 1FEC6407F1; Wed, 2 Jun 2021 05:23:40 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id DDA54402DB for ; Wed, 2 Jun 2021 05:23:38 -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 bmf2xk-mds2q for ; Wed, 2 Jun 2021 05:23:37 -0400 (EDT) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 90317406D3 for ; Wed, 2 Jun 2021 05:23:37 -0400 (EDT) Received: by mail-wm1-f54.google.com with SMTP id f20-20020a05600c4e94b0290181f6edda88so3322649wmq.2 for ; Wed, 02 Jun 2021 02:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WmVa2b7NUFKbzMkhRQoxLzdNVa4IgoT+niyCi15lBaU=; b=fJRU2AeKIPcQx11KLen+Ij89vZ+kwU0B8R7ieQATn/S0NLwL1fvRl5LLh3ACQr34HC O/8C0RF/0XjOPLbaQwJxsyQTmFiVL+Csf6hhVR3MNdjIKQDCPOwwgZZMoGIc35TOnpPe pYii0GAXsOF3dYFSG/Q0zJeCb6QtDpn02L6GGQSwx7MZ9E9s317Gsikz/vHIA3HLacl9 3ZZRtTIXdgDwIgatsDJ1EBqZI7eZWxX4fgyowEP5VzxlJvcFR/j5QGj3pUgUr+hlWyY5 d0JiS7tPfNQp6xOkVawGkmAOHWLu632QX4JEKAoYuAX+6eVgjx1gIPD/QQsd63szgsgx 218A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WmVa2b7NUFKbzMkhRQoxLzdNVa4IgoT+niyCi15lBaU=; b=iJK+5e1WvJo8CXT1+uawIm9CpGy0PNjf5mRBf4vDijIQ3hLwUduIKWQ2+bBJYlEC9h 5zFik3dcqurNPJ47fenReSVX+rsOYj3SIsl3Tll71s0bZ72jzWeYKIjU3TyG4fLS/By3 DGg1fjnBEzJCxDnkIulh4L35cFTxMldu1MEarrkdboVJL5WucCvyPSU5gIKZHg8DQelh BZuyi1/tvMmfrX1lp3zNP1m8NfDqkHwkD88+5U3/FE+7LBwGXCEIUcHi25RJdN1PQbgs aAJ2B3OXksZdQpV1UPL8YNwYt0GAVmuYQgB8WX24wMJpH4z3CZ/Y//A/Xcm72A3a8VRS T+PQ== X-Gm-Message-State: AOAM531h4otxOUSrPPkwocZSvrjq8Md0/AOU1lv0gZ1lmYtyI2KkpllY CYe2CC5lj07iAhWgpEZl2iq4Dw== X-Google-Smtp-Source: ABdhPJxrBmcIQdy1jyLXdbeY8xm3r2YATiuKPsOu+SRZUU2eDFxWBsAmhIOgoXGcJfVGwfjPxAVmew== X-Received: by 2002:a1c:f016:: with SMTP id a22mr31888176wmb.65.1622625816371; Wed, 02 Jun 2021 02:23:36 -0700 (PDT) Received: from google.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id h14sm2009325wmb.1.2021.06.02.02.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 02:23:35 -0700 (PDT) Date: Wed, 2 Jun 2021 09:23:33 +0000 From: Quentin Perret To: Marc Zyngier Subject: Re: [PATCH 3/7] KVM: arm64: Remove list_head from hyp_page Message-ID: References: <20210527125134.2116404-1-qperret@google.com> <20210527125134.2116404-4-qperret@google.com> <87k0nd1wgx.wl-maz@kernel.org> <87fsy11nz6.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87fsy11nz6.wl-maz@kernel.org> 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 Tuesday 01 Jun 2021 at 18:41:49 (+0100), Marc Zyngier wrote: > 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. Right, so I'd prefer keeping it void * for consistency with the EL1 equivalent -- much of this aims to be API compatible with the Linux stuff. I'll get rid of the cast and post a v2 shortly. Cheers, Quentin _______________________________________________ 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.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 9A815C47083 for ; Wed, 2 Jun 2021 09:25:20 +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 57B2C610A8 for ; Wed, 2 Jun 2021 09:25:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 57B2C610A8 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=5HQKpLOfQrpMY56FGXA9DeezS2e/fTAQgO78eQkO2pI=; b=hTtlZ6KTsVea1O RM+TEl8Q3ikv7RC5Oxv4oaJEHdlBJ0Hq6MQIUvzGn8ik7SZyLdCafdKh3drQ1v9WZi7W7tSbHUYxc QGHyOyrS4PbP8R0q1bTWRPU5vSJh7UP2P0w5r8A59yUUBN3qlMJhUS2mbAlI4fhnq/JJJSelLU4+s Vtp0m3nG9P+yc8tsnOExcp7Jg9wnpCDFmImvZukm9FkXvKPAUHdc3REuiZ4xdKnJtnqx+CtK4YQ59 Om69U8V9O/IAdYTTFf1OCq8WDeIxKCvKtJIrkNCpcMtYMjqR7DrG23v31c5gn0Gou5vfOhBw9ouKL GKB6YvlOSuC1Ij6ZdhOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loN6G-002wbp-RB; Wed, 02 Jun 2021 09:23:45 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loN6D-002wbC-0f for linux-arm-kernel@lists.infradead.org; Wed, 02 Jun 2021 09:23:42 +0000 Received: by mail-wm1-x332.google.com with SMTP id n17-20020a7bc5d10000b0290169edfadac9so3322094wmk.1 for ; Wed, 02 Jun 2021 02:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WmVa2b7NUFKbzMkhRQoxLzdNVa4IgoT+niyCi15lBaU=; b=fJRU2AeKIPcQx11KLen+Ij89vZ+kwU0B8R7ieQATn/S0NLwL1fvRl5LLh3ACQr34HC O/8C0RF/0XjOPLbaQwJxsyQTmFiVL+Csf6hhVR3MNdjIKQDCPOwwgZZMoGIc35TOnpPe pYii0GAXsOF3dYFSG/Q0zJeCb6QtDpn02L6GGQSwx7MZ9E9s317Gsikz/vHIA3HLacl9 3ZZRtTIXdgDwIgatsDJ1EBqZI7eZWxX4fgyowEP5VzxlJvcFR/j5QGj3pUgUr+hlWyY5 d0JiS7tPfNQp6xOkVawGkmAOHWLu632QX4JEKAoYuAX+6eVgjx1gIPD/QQsd63szgsgx 218A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WmVa2b7NUFKbzMkhRQoxLzdNVa4IgoT+niyCi15lBaU=; b=s2y9VjLpgkVD2HOENe98Y1kCCMOEvxstHKVTORc4Ocf75kiE4StdBo0a9adl7GkupG WkrWCyHsQGOX8ZxtNJNCQbX9P3ayxqTaVKj+iAZSzUXC3+QxFza4N6vUcFrpP58r/I3v z9wBca4fRQK9yOJdJdzu5SbBYXMYkr361Qh5NrDmA+ROX2XEPmN2RNh47wCXXAzXlEg0 WoMtGrEUO7ZkYudiwnN0lO004lSebgl5fXffW1Szo7zXISm42FM1llGl01uo2v0n+PZP XEjWAJpuAuFEvvvvH7Idsr2CVSC5pjbskgYjUP49iqM6eB/S1MMxOGauGsKg038DkRAC vSOg== X-Gm-Message-State: AOAM533rTXLFBMdLw8y5E6esWGkshQ7LYktEPmznIEQPpYIj89m6svFc uEZWmZBGEBKgi7iu8k7HVSgOww== X-Google-Smtp-Source: ABdhPJxrBmcIQdy1jyLXdbeY8xm3r2YATiuKPsOu+SRZUU2eDFxWBsAmhIOgoXGcJfVGwfjPxAVmew== X-Received: by 2002:a1c:f016:: with SMTP id a22mr31888176wmb.65.1622625816371; Wed, 02 Jun 2021 02:23:36 -0700 (PDT) Received: from google.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id h14sm2009325wmb.1.2021.06.02.02.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 02:23:35 -0700 (PDT) Date: Wed, 2 Jun 2021 09:23:33 +0000 From: Quentin Perret To: Marc Zyngier 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 Message-ID: References: <20210527125134.2116404-1-qperret@google.com> <20210527125134.2116404-4-qperret@google.com> <87k0nd1wgx.wl-maz@kernel.org> <87fsy11nz6.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87fsy11nz6.wl-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210602_022341_103243_0006213D X-CRM114-Status: GOOD ( 25.33 ) 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 Tuesday 01 Jun 2021 at 18:41:49 (+0100), Marc Zyngier wrote: > 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. Right, so I'd prefer keeping it void * for consistency with the EL1 equivalent -- much of this aims to be API compatible with the Linux stuff. I'll get rid of the cast and post a v2 shortly. Cheers, Quentin _______________________________________________ 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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 772ECC47092 for ; Wed, 2 Jun 2021 09:23:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53021613B1 for ; Wed, 2 Jun 2021 09:23:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231722AbhFBJZW (ORCPT ); Wed, 2 Jun 2021 05:25:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230250AbhFBJZU (ORCPT ); Wed, 2 Jun 2021 05:25:20 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEE15C061574 for ; Wed, 2 Jun 2021 02:23:37 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id l18-20020a1ced120000b029014c1adff1edso3312818wmh.4 for ; Wed, 02 Jun 2021 02:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WmVa2b7NUFKbzMkhRQoxLzdNVa4IgoT+niyCi15lBaU=; b=fJRU2AeKIPcQx11KLen+Ij89vZ+kwU0B8R7ieQATn/S0NLwL1fvRl5LLh3ACQr34HC O/8C0RF/0XjOPLbaQwJxsyQTmFiVL+Csf6hhVR3MNdjIKQDCPOwwgZZMoGIc35TOnpPe pYii0GAXsOF3dYFSG/Q0zJeCb6QtDpn02L6GGQSwx7MZ9E9s317Gsikz/vHIA3HLacl9 3ZZRtTIXdgDwIgatsDJ1EBqZI7eZWxX4fgyowEP5VzxlJvcFR/j5QGj3pUgUr+hlWyY5 d0JiS7tPfNQp6xOkVawGkmAOHWLu632QX4JEKAoYuAX+6eVgjx1gIPD/QQsd63szgsgx 218A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WmVa2b7NUFKbzMkhRQoxLzdNVa4IgoT+niyCi15lBaU=; b=Jplowd79URXOAs6hoXAUrG5P2nyQ3T2hU99lJgNpMGywgVeRtQvmETfcH8SBeYV1fp OT8LCCvKEjVbFtEqcvZ2Q+BprFpTDO4XfoPt/4b8I+ZTAW+BuaZdI5kD1TsvhYBH+tKh ati2lRZixdH015SulmMSBvwBjFBZ2Dbc1KX3ISbW4WM7CvBhH8XCXB61nKGFKtzw0bTn kLvlu5qgjXR6Hi3BcP49LRxm1t/q61Ki2AOLvMQGJh5uugMR8XxYIicNKFvAriAgUnmL JhO79tAZRSPQ987Hvtr2fsW2hTHe07Z6/nB+cBrsPL2DLduph1ELQf/UHzhdI5vzQV/B 5a1Q== X-Gm-Message-State: AOAM532V2qRD2sCkyk6HQZY4r+JqAhjMIKmh050OAZ4X7N5lGcXa4tX9 jZ6igWCRgdCf0ZHsLB0WmnDI+w== X-Google-Smtp-Source: ABdhPJxrBmcIQdy1jyLXdbeY8xm3r2YATiuKPsOu+SRZUU2eDFxWBsAmhIOgoXGcJfVGwfjPxAVmew== X-Received: by 2002:a1c:f016:: with SMTP id a22mr31888176wmb.65.1622625816371; Wed, 02 Jun 2021 02:23:36 -0700 (PDT) Received: from google.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id h14sm2009325wmb.1.2021.06.02.02.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 02:23:35 -0700 (PDT) Date: Wed, 2 Jun 2021 09:23:33 +0000 From: Quentin Perret To: Marc Zyngier 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 Message-ID: References: <20210527125134.2116404-1-qperret@google.com> <20210527125134.2116404-4-qperret@google.com> <87k0nd1wgx.wl-maz@kernel.org> <87fsy11nz6.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87fsy11nz6.wl-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday 01 Jun 2021 at 18:41:49 (+0100), Marc Zyngier wrote: > 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. Right, so I'd prefer keeping it void * for consistency with the EL1 equivalent -- much of this aims to be API compatible with the Linux stuff. I'll get rid of the cast and post a v2 shortly. Cheers, Quentin