From nobody Mon Feb 9 16:35:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1615373197; cv=none; d=zohomail.com; s=zohoarc; b=VWfb9eE3yNZPEVVaCZ1ud/RuSr7z0Jsl5RYaee8647Zg3ZaLQFp3SglP4zrY34mjXEticwzqhYkEbnH0PJfFeI53ghvoObJbUV8A33eOX8R4cH7ULLgU/mBMwQ3eFR0wQdskEBMOVQI1F3Zyz9qCmNH12pSsyxVbMe8k9smqybY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615373197; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yvUHprKx53TaVD+UfRnNYW7HFBxwI5hyLFfjImK+NmI=; b=lVZxmIIrgFFi0Rb3QzuJeqAgdfpGt3H7JaehcRMPkW3v4F13NJ4QOw08nMhcFJiFV7u+y4gxsBtn4iIL6QGiu4ZnIRGANtytPkIbtAD1af0oYeU8jQGmUBG078wa7fT/8ZIs1qVVPNVbzJxHUZ1AgMllwnBJGXsohSdsvLSxta8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 161537319791521.465256083594795; Wed, 10 Mar 2021 02:46:37 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.95989.181329 (Exim 4.92) (envelope-from ) id 1lJwM4-0003ws-A3; Wed, 10 Mar 2021 10:46:16 +0000 Received: by outflank-mailman (output) from mailman id 95989.181329; Wed, 10 Mar 2021 10:46:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lJwM4-0003wl-7A; Wed, 10 Mar 2021 10:46:16 +0000 Received: by outflank-mailman (input) for mailman id 95989; Wed, 10 Mar 2021 10:46:14 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lJwM2-0003wc-Dt for xen-devel@lists.xenproject.org; Wed, 10 Mar 2021 10:46:14 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 74e6b74e-0ced-4df2-982c-200d980c9508; Wed, 10 Mar 2021 10:46:13 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 017F9AC24; Wed, 10 Mar 2021 10:46:13 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 74e6b74e-0ced-4df2-982c-200d980c9508 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1615373173; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yvUHprKx53TaVD+UfRnNYW7HFBxwI5hyLFfjImK+NmI=; b=a08Avz/NSZFWEZLSEKggtjR0QaOpO0YEpvzKqyclVcRIFKKhJbYKiTYvp9GBR9sKc42uD9 7kH517gdlU6BcVbC0XhfYHMVO3pKWDGRVamM3iP6bt4YNG+m07xcUlKLf9x8yUJ5ytwsNC 29dfs0qEwcXQfvpA3NXgXe5G6i84mDU= Subject: [PATCH 3/3] Xen/gntdev: don't needlessly use kvcalloc() From: Jan Beulich To: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Cc: "xen-devel@lists.xenproject.org" References: <2b326dc6-c624-c97b-f9c4-4cc68dd013ba@suse.com> Message-ID: <9a726be2-4893-8ffe-0ef1-b70dd1c229b1@suse.com> Date: Wed, 10 Mar 2021 11:46:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <2b326dc6-c624-c97b-f9c4-4cc68dd013ba@suse.com> Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Requesting zeroed memory when all of it will be overwritten subsequently by all ones is a waste of processing bandwidth. In fact, rather than recording zeroed ->grants[], fill that array too with more appropriate "invalid" indicators. Signed-off-by: Jan Beulich Reviewed-by: Juergen Gross --- v2: Use (now generalized) INVALID_GRANT_REF. --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -133,9 +133,12 @@ struct gntdev_grant_map *gntdev_alloc_ma if (NULL =3D=3D add) return NULL; =20 - add->grants =3D kvcalloc(count, sizeof(add->grants[0]), GFP_KERNEL); - add->map_ops =3D kvcalloc(count, sizeof(add->map_ops[0]), GFP_KERNEL); - add->unmap_ops =3D kvcalloc(count, sizeof(add->unmap_ops[0]), GFP_KERNEL); + add->grants =3D kvmalloc_array(count, sizeof(add->grants[0]), + GFP_KERNEL); + add->map_ops =3D kvmalloc_array(count, sizeof(add->map_ops[0]), + GFP_KERNEL); + add->unmap_ops =3D kvmalloc_array(count, sizeof(add->unmap_ops[0]), + GFP_KERNEL); add->pages =3D kvcalloc(count, sizeof(add->pages[0]), GFP_KERNEL); if (NULL =3D=3D add->grants || NULL =3D=3D add->map_ops || @@ -143,10 +146,10 @@ struct gntdev_grant_map *gntdev_alloc_ma NULL =3D=3D add->pages) goto err; if (use_ptemod) { - add->kmap_ops =3D kvcalloc(count, sizeof(add->kmap_ops[0]), - GFP_KERNEL); - add->kunmap_ops =3D kvcalloc(count, sizeof(add->kunmap_ops[0]), - GFP_KERNEL); + add->kmap_ops =3D kvmalloc_array(count, sizeof(add->kmap_ops[0]), + GFP_KERNEL); + add->kunmap_ops =3D kvmalloc_array(count, sizeof(add->kunmap_ops[0]), + GFP_KERNEL); if (NULL =3D=3D add->kmap_ops || NULL =3D=3D add->kunmap_ops) goto err; } @@ -186,6 +189,8 @@ struct gntdev_grant_map *gntdev_alloc_ma goto err; =20 for (i =3D 0; i < count; i++) { + add->grants[i].domid =3D DOMID_INVALID; + add->grants[i].ref =3D INVALID_GRANT_REF; add->map_ops[i].handle =3D INVALID_GRANT_HANDLE; add->unmap_ops[i].handle =3D INVALID_GRANT_HANDLE; if (use_ptemod) {