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 B32FDC4708F for ; Tue, 1 Jun 2021 15:48:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90B5D61396 for ; Tue, 1 Jun 2021 15:48:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234462AbhFAPuF (ORCPT ); Tue, 1 Jun 2021 11:50:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234446AbhFAPt4 (ORCPT ); Tue, 1 Jun 2021 11:49:56 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11EE6C061574 for ; Tue, 1 Jun 2021 08:48:11 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id z8so9752001wrp.12 for ; Tue, 01 Jun 2021 08:48:10 -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=wEwX9WZesArWKsstP4MgeMs+pB7+trRKG9aUiLAejfI=; b=j7funsS3lgOohm05QYVU+t8GGWwgu0Wf20fsocDj/LBWHAlMAMRLryyp9qyZQdrJzs 19JU1dDbayAu7X9IC/gXiuse+1XBdQMfra6E8X8im1Yf2OuhFVB2afWXKUoinPmFOOsT WPj3A3VI2jJ9+9fQQNj9JN6DPMCpDDlgMtYnZFDqsVHiJGEBq/t0E30gB5368QBOEng3 t09QPgcYsVUjhowSdXx8Ng0XLom4WcaVit5zzpCJYbZ9aVUisMW4KnUnndLFhcGfPzsj 4BhVindCVW1K6mhnWo+HBMMbmTXdM22cbOPjRiJqXlAQK73xamnHyuk/u/yMHQtVVMUS IC+Q== 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=wEwX9WZesArWKsstP4MgeMs+pB7+trRKG9aUiLAejfI=; b=XdqwTnP69nmJsfQSNeU7vph1jhvPaI2XXWv2ovKNOOrjqChXntebbZShd7d6VKjLCl a5jaJUKt4kJB/IjcgRuAdr5uvZFfsXRsRW1AGd4NTDbk10AqLUm3R/q2U2wUuMXq9A28 b7fyCMt7+/UrKk3jmiBxkZm1FV6kHidmnUHkImoyNuRhT6IrLA5H1JzldmFnIFnzK+fK iKnABQ7yQkGQUt//SZXuNxh8kJ25WKatvh97g/DD521VrDYUs8tc7kaFZ5ZPqi6hQdMz FG87CFw7QWMXo6bQvBlw/LZ7XFYXIVHLlTHuoiYWhgE5ZKqYZ8QzSqL7r0vq/Za5H8aU o4yA== X-Gm-Message-State: AOAM533mlualqFoQdLF7XNTNzeKmA53K40cclRMUpBFgmtPNSgSbPFnb zMWGYoveCzGtRFNLRH/ILKokjA== X-Google-Smtp-Source: ABdhPJypLSgdyQrzYGtYN1BysUUWmR3te0VbHpPr02pGuGIYnfWllUWNT85DgCvXAJ1Jr1mor+fMhQ== X-Received: by 2002:a5d:50c1:: with SMTP id f1mr29105131wrt.168.1622562489528; Tue, 01 Jun 2021 08:48:09 -0700 (PDT) Received: from google.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id b15sm3342934wru.64.2021.06.01.08.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 08:48:08 -0700 (PDT) Date: Tue, 1 Jun 2021 15:48:06 +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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87k0nd1wgx.wl-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > + > > + __list_del_entry(node); > > + memset(node, 0, sizeof(*node)); > > +} > > + > > +static inline void page_add_to_list(struct hyp_page *p, struct list_head *head) > > +{ > > + struct list_head *node = (struct list_head *)hyp_page_to_virt(p); > > + > > + INIT_LIST_HEAD(node); > > + list_add_tail(node, head); > > +} > > + > > +static inline struct hyp_page *node_to_page(struct list_head *node) > > +{ > > + return (struct hyp_page *)hyp_virt_to_page(node); > > Why is this cast necessary? If I'm not mistaken, hyp_vmemmap is > already cast as a 'struct hyp_page *', so hyp_virt_to_page() should > return the same type. Right, that one is totally unnecessary, I'll remove. Cheers, Quentin 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 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 3433DC4708F for ; Tue, 1 Jun 2021 15:48:15 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id A379F6136E for ; Tue, 1 Jun 2021 15:48:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A379F6136E 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 1B4C14B0C4; Tue, 1 Jun 2021 11:48:14 -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 YQOxEHzw8+xz; Tue, 1 Jun 2021 11:48:13 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id F36124A32E; Tue, 1 Jun 2021 11:48:12 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id D13E649E5F for ; Tue, 1 Jun 2021 11:48:11 -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 WpOXdxhf14DN for ; Tue, 1 Jun 2021 11:48:10 -0400 (EDT) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id BFD0D40895 for ; Tue, 1 Jun 2021 11:48:10 -0400 (EDT) Received: by mail-wr1-f46.google.com with SMTP id q5so14863896wrs.4 for ; Tue, 01 Jun 2021 08:48:10 -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=wEwX9WZesArWKsstP4MgeMs+pB7+trRKG9aUiLAejfI=; b=j7funsS3lgOohm05QYVU+t8GGWwgu0Wf20fsocDj/LBWHAlMAMRLryyp9qyZQdrJzs 19JU1dDbayAu7X9IC/gXiuse+1XBdQMfra6E8X8im1Yf2OuhFVB2afWXKUoinPmFOOsT WPj3A3VI2jJ9+9fQQNj9JN6DPMCpDDlgMtYnZFDqsVHiJGEBq/t0E30gB5368QBOEng3 t09QPgcYsVUjhowSdXx8Ng0XLom4WcaVit5zzpCJYbZ9aVUisMW4KnUnndLFhcGfPzsj 4BhVindCVW1K6mhnWo+HBMMbmTXdM22cbOPjRiJqXlAQK73xamnHyuk/u/yMHQtVVMUS IC+Q== 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=wEwX9WZesArWKsstP4MgeMs+pB7+trRKG9aUiLAejfI=; b=GYa8LvZp/FNdoWorYj7jf6fUUdlM49RzitsDTUlY+hTnFtDK7yHZiK9bK0/pPfflpW CKHZgA8EXjLCnnatO1cWM9GOvkhqe35gvF6xjystginZEV76nNTMPQiToBccEH4B3YGL THtIRM0IOIp8wfDGqrAr/GcuCUcOlw89g5VLICxkoFgi/zIstdw70RJKvhVpfSbSyWQv 80jFzkowylv64nkY3yGIClOiwkG1Pelm2MLhl3YapYGAkBAT7Jpr5u3RsJKFsOnjdJ1h eSCZICOSFgF0aK8FeuNV5QlJh/WKWlfv+OPJypqQ8W6VLHUGhdVTrSLSCaTdUE6FkOmA xV5A== X-Gm-Message-State: AOAM533ZryCWUnOnnjVJUkhkOvmo2pC1LSS0QVWiX9sSlGzEW2PDJ3X3 +ciN/2bZxcTe4MNHOlNfQrtOTQ== X-Google-Smtp-Source: ABdhPJypLSgdyQrzYGtYN1BysUUWmR3te0VbHpPr02pGuGIYnfWllUWNT85DgCvXAJ1Jr1mor+fMhQ== X-Received: by 2002:a5d:50c1:: with SMTP id f1mr29105131wrt.168.1622562489528; Tue, 01 Jun 2021 08:48:09 -0700 (PDT) Received: from google.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id b15sm3342934wru.64.2021.06.01.08.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 08:48:08 -0700 (PDT) Date: Tue, 1 Jun 2021 15:48:06 +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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87k0nd1wgx.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 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. > > + > > + __list_del_entry(node); > > + memset(node, 0, sizeof(*node)); > > +} > > + > > +static inline void page_add_to_list(struct hyp_page *p, struct list_head *head) > > +{ > > + struct list_head *node = (struct list_head *)hyp_page_to_virt(p); > > + > > + INIT_LIST_HEAD(node); > > + list_add_tail(node, head); > > +} > > + > > +static inline struct hyp_page *node_to_page(struct list_head *node) > > +{ > > + return (struct hyp_page *)hyp_virt_to_page(node); > > Why is this cast necessary? If I'm not mistaken, hyp_vmemmap is > already cast as a 'struct hyp_page *', so hyp_virt_to_page() should > return the same type. Right, that one is totally unnecessary, I'll remove. 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 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 48EE5C47080 for ; Tue, 1 Jun 2021 15:49:36 +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 0821E6136E for ; Tue, 1 Jun 2021 15:49:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0821E6136E 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=1TsDPLniJsIfwEo6CuT///rRDpkaBW7i7jGaFb8QGPY=; b=e8es+lhQ32SGNx YWc3w6WaIlxa+fpNtgZRbibR2bhc2TSKKsnj1dj3cz9duNXrSMTPAYDShXeXvN+1uoFBmRLbC+tlR EFhWwL62qt5i+r57fLWBorl4rQ8oCavCh6DewBuUj3HFk2fzk2ORp6Z0OLFXTg988ToO7yfT8Yn4a epAsr7m2bRn7hA+e3HTyPhFrzxT9LIHejuRavG4r9zJRKj4Mj3bvZJ5r5R6VpgSqhlY6U8YkQMl5b +sYRI78czQ/LuUrkdJ16dPdjBWbozaRyRE+DVvxNcnUS2GvQ6Qg/BzHdpsqgkvAaimUkGzzVQ6YcL KRTxXfTnmJnGGyIWc3iA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lo6co-00HJVF-GA; Tue, 01 Jun 2021 15:48:14 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lo6ck-00HJTL-TV for linux-arm-kernel@lists.infradead.org; Tue, 01 Jun 2021 15:48:12 +0000 Received: by mail-wr1-x42f.google.com with SMTP id q5so4220623wrm.1 for ; Tue, 01 Jun 2021 08:48:10 -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=wEwX9WZesArWKsstP4MgeMs+pB7+trRKG9aUiLAejfI=; b=j7funsS3lgOohm05QYVU+t8GGWwgu0Wf20fsocDj/LBWHAlMAMRLryyp9qyZQdrJzs 19JU1dDbayAu7X9IC/gXiuse+1XBdQMfra6E8X8im1Yf2OuhFVB2afWXKUoinPmFOOsT WPj3A3VI2jJ9+9fQQNj9JN6DPMCpDDlgMtYnZFDqsVHiJGEBq/t0E30gB5368QBOEng3 t09QPgcYsVUjhowSdXx8Ng0XLom4WcaVit5zzpCJYbZ9aVUisMW4KnUnndLFhcGfPzsj 4BhVindCVW1K6mhnWo+HBMMbmTXdM22cbOPjRiJqXlAQK73xamnHyuk/u/yMHQtVVMUS IC+Q== 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=wEwX9WZesArWKsstP4MgeMs+pB7+trRKG9aUiLAejfI=; b=bqal7OoIUcT2nXI4EiHRYtETBW8bHxO8THsnY5HFivkssDlFGtyYJLRpgcyc1onXer +QAwuEqaPsjviybbakXSudVno6dHGB2jbqdHjzceJ6HEdwUktUQqx85tmitNcR4O26bC epFnMLEd/zw0Gp6APjmTxRcqTKhGJ5QbjEOylADe7StAjFulEob/SNYM+x/UEy/k/hlh GnKRRynPv4RPVl3PXIoZTwih2B2J3lBM1tadUWhKEJhMfMwEx8TJN7kxzfnsI27QyBoG /5g2Nw7oaRdeXgTyl3uvuq5KLUk2bNtK+fBdVCmDy7oDHt8GwLOVf5NxuuGe6z/LEygZ qE7w== X-Gm-Message-State: AOAM531h9JwsWPvtP70W5yaTQPADTXsMITcox6U8g9W4ZOeKotHB9vNz xbPYcecj4XEiMZeC0gURJowFgdQm9UDltg== X-Google-Smtp-Source: ABdhPJypLSgdyQrzYGtYN1BysUUWmR3te0VbHpPr02pGuGIYnfWllUWNT85DgCvXAJ1Jr1mor+fMhQ== X-Received: by 2002:a5d:50c1:: with SMTP id f1mr29105131wrt.168.1622562489528; Tue, 01 Jun 2021 08:48:09 -0700 (PDT) Received: from google.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id b15sm3342934wru.64.2021.06.01.08.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 08:48:08 -0700 (PDT) Date: Tue, 1 Jun 2021 15:48:06 +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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87k0nd1wgx.wl-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210601_084810_992582_C4E5F21A X-CRM114-Status: GOOD ( 21.42 ) 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 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. > > + > > + __list_del_entry(node); > > + memset(node, 0, sizeof(*node)); > > +} > > + > > +static inline void page_add_to_list(struct hyp_page *p, struct list_head *head) > > +{ > > + struct list_head *node = (struct list_head *)hyp_page_to_virt(p); > > + > > + INIT_LIST_HEAD(node); > > + list_add_tail(node, head); > > +} > > + > > +static inline struct hyp_page *node_to_page(struct list_head *node) > > +{ > > + return (struct hyp_page *)hyp_virt_to_page(node); > > Why is this cast necessary? If I'm not mistaken, hyp_vmemmap is > already cast as a 'struct hyp_page *', so hyp_virt_to_page() should > return the same type. Right, that one is totally unnecessary, I'll remove. Cheers, Quentin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel