Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3597292pxj; Tue, 1 Jun 2021 08:49:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUVeDBR8ScMpngRfUXugcevgYKlbi+8SKdMTW0EC55TYkpNf9CutwAOCAxSwtA9rk1FR9M X-Received: by 2002:a17:906:ecbc:: with SMTP id qh28mr363005ejb.406.1622562588161; Tue, 01 Jun 2021 08:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622562588; cv=none; d=google.com; s=arc-20160816; b=nudNid46iPFSYmjBvMcZBDTnuwOAxmRusMWCdgeDlErKcv0BDVcocgw1SE5C6FcQu0 VzirP9bZ7qrDVWUajN723oAw4RPIVzp1Gbh5L12r+26XwzW/MXAefRYB0IISvfoyX+Q+ jTOV+B4bMt24aJ7tFK/HlGj8jF90MIB/nEI/1SDoVjdNTreBQSXBvqQvF0dAQ+CyGUCU bh+YDHqMCHW+h7az2nClUtzACPh5wsCPOwgXZSmSRgWnYDJhF/ih5McQ93GWLbqDwZmI MdtS5tARO1DFP9QIbxKxYmtiEwIu4e/xwvP+YFSUz/peJj5o9tKLQb3ZdDiwdgyqI38d TDqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wEwX9WZesArWKsstP4MgeMs+pB7+trRKG9aUiLAejfI=; b=CjqrRjpYuq1SHTOVrC9fGxTvQ6z05dMwBb0CQ94AOGVXyDBn5+GblinMre5VNrOhyZ yigUWjMA3RH9qlDJR/GWAbTZrH68P6VVEqiQRYGTA2DdCf7Han2M8awW8Xsk9KjnOeSv Cc9kkDhagttBbOiooHWfdXD01IrF9EJttnRGM8fX23HJeS5Q0CftF0YesmaXdHth3JQ8 G2E0A257TXoxYmSj0jJSXL4cqNgOiFRhW5vHuhKMOaYuhjwCncrTh8MwqPF+Mn3GtWo4 kvg65znX/T/iGJ5Ags35CR/t5EANT71QHgrRoOQ785vyBVYkP7f9zIpxxuAb9L+FWzov V/Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=j7funsS3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d5si16847125ejz.328.2021.06.01.08.49.25; Tue, 01 Jun 2021 08:49:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=j7funsS3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234457AbhFAPt7 (ORCPT + 99 others); Tue, 1 Jun 2021 11:49:59 -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-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