From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796299656; b=iLBa267fkRodKB+95E00pGzsfDmAVEXfilS9IoDUNyQ9yFgITTxqfhEFAavd3KMF7pRT 54etiU5AP2lbuh+aQX570fWwoHh1EP1w17FFinkhIVxIu2309qlNuPpyteEiIZLbKQzKh cZFO+l/w+oJb2asDjLrplYiR0exW7IVT0aQ26DggAn9ZFhy+XXxcgivsfn+GIj4Ld2J8T iThc138JzkgbXJmOyDIrAMTdrxuNMjgzQgoQ89lOJEotwwX8K4yH09ybevU1yDe2ZpbBK sNSBEHSTaQeOl0B8HAPz6MIOsEdUmHKeTnCVJWuMmd057m6RrI4KNt86mHVJcSIjEow== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796299656; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=E0urAu7jaUUwfABJ0h57RmnESefbsbVbMoGI2xju5oY=; b=S5IIBDCNzVeinn3lXXgVQy9iFHf5A+xfJqjuqdCyz/0T+JY5XAU1s2D13v4I/lGzPk/v InaymCAcLpgpm70S1o0YX9m42Rd538F5i5VQ10wB0kmVBMJcDHZRig7N1gokO6DYMxTvr O7o3uT3HBmIZi1D1jW3Hu8Brh1L/bsV7yFeQrOjZQB3Y5UXW/DG5WxwA4Atwc3mq9nBHK 1iKzFHqLFlu29YDXV3D86iJS/RsTbIjKZjql40x7h9B4Xf7xSG/nwmwRaXWJwdOB1ApSj VOYO4aa5puxJ3AJzOXTegOSbm/J/TLfIFvuCCmQPd+Zr0ALfDy1dhDL0ZEMMSEovcGg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b="hg0jR5i/"; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b="Nnw84M/3"; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6B0A606A332 for ; Thu, 3 Dec 2026 12:07:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D6B0A606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hg0jR5i/; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=Nnw84M/3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796299654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E0urAu7jaUUwfABJ0h57RmnESefbsbVbMoGI2xju5oY=; b=hg0jR5i/QbE7bhvcyQfSyIdXTQE8qDDtO56lu/WMIOKH3/Rsl7nhKbVxBUjokb+yfnxgZa xx2MFrmnzDbm7ty4nyL3NPGw0JqdOGNI01Qt7ag8G/jQSb2O0DCNB4YgRej4HhC2CQXH6F sYuiUbP703iubGCgmuQ7WEE4go79Otw= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-60-Mb_QjDARPf6FDT2EKU7JZQ-1; Thu, 3 Dec 2026 12:07:32 +0000 X-MC-Unique: Mb_QjDARPf6FDT2EKU7JZQ-1 X-Mimecast-MFC-AGG-ID: Mb_QjDARPf6FDT2EKU7JZQ_1796299652 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4bb8da397aaso6736725e9.0 for ; Thu, 03 Dec 2026 04:07:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1796299651; x=1796904451; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=E0urAu7jaUUwfABJ0h57RmnESefbsbVbMoGI2xju5oY=; b=Nnw84M/3lH6WSF4iCUbOEE7dgfupjRllZQrdLhTtkV5C+ZE2RgOdPr5Q79gnVxes7Q RdmgT136ZL97sPO+htulPUo2B+NDoTH4u9cNjKoQb6qppYa+F6E3qPu4j/XOpNN4nm6z 4dgw0hAz7hOinmyf0hCkh279sOOH5pcuWbzPJpuryJi/BFu+RJO7qMyPmRLaUQqElckk 9t/NXDPMY/TgNo6f8FD0Pd1KnrcRKwv/pMLMiCRx6m30EuzkCD5OeJCruuOuRH8gUTV4 E5iHxbWB1QROF+b+GkFlY4iqOYtkr25oZ74SZBwhf2rM9zuJNVOPUrWZATE7m8fb96sZ 1P1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796299651; x=1796904451; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=E0urAu7jaUUwfABJ0h57RmnESefbsbVbMoGI2xju5oY=; b=lH9lbd0K58TCxg9HYJql8b7tvbQQAXRnvq63YwqO2BwyXL9QrbxWJ3Xv1LBV0ym+lH G9Bm/rCmvnxOvDA25b0XqgHlOsHeZddU4BNqJxZjFSA3o6sQT7qBQ2kjfZzm1r8BVvf8 K7Fco6O1V4IjqI6gG/UHX95hQuBFemjpMatAvqCuhq+5fjicQPItOVWG2wlmUIo4RZtb 7dkJUOCss4IkGwxILkDd81OpfJ+1Fo+w3n1ZDC5lCny7+RBNbszM+dA2F3eIv7mQtaQj SEmdV3DZgY0BbXzPcx9RgwvJKmgoSmvZpLWjXcb+HYUCrqUQc1VgB8sLeZMyYOGBaUEI aC+A== X-Forwarded-Encrypted: i=1; AL+hErE3Z9yImoRkmuwtn+8WbWOS0yzaXnVgQ2+r3PqcjRbqc/6l9XztvgbQ57ee/2dXhigqeqA=@vger.kernel.org X-Gm-Message-State: APuU4Z/bGPlXJBaDDm5+cmEvpzfEb1w9Js97CNzrQVBk4z3HBhwdOmbx q65iDAJzIOrhHfmDmZZ+hPV74TIUapTIxCGlyoZ54N9NhuTT8a6tH+Sw7VgnUmZJZ5m/SSsVrRv J/vbJfDjS40hcOpvYgv/wU0HbDNWfuSACvzsF8m5j04kT5Xrqit3bpQ== X-Gm-Gg: AZFdTZcw2qNCM87Q5Fnj7US2rMdzh477/T+70mI2J8JxZ9xzi+g1JpF05RLqZyWSWC5 lK9ZJqNxuxzO+iGhiKqCJ10j/kxZLWUtBCOsX3BOLe1ft0Ng7+R4HCK8lLOXO7YLBO1j5X3V8hH wYAAud2s+JgtkDAeiPmsuARxZENDzGE1qZLz0I7hWp+d5IqxJ+qvOCGJy4eo/JghrShPfA+vnqw SBqyhxvmWS7DqZBPNM0RxLSudMTcONUKId85aeI1igfqZtlF23FzFe3PHragWUPUjdl8a3+Ee9z 4Ye6t4pIonmJb3VD25ie0No77BvZenv7lNnRV1fa2m9/+bCb09I700gtjkpavUzHe7FIOuVRT1C /02906hJMi626FgxiR8qhYMhvteinaVETSlU2votyOA== X-Received: by 2002:a05:600c:848d:b0:4a1:c27d:e1a8 with SMTP id 5b1f17b1804b1-4bbe198418fmr31646725e9.10.1796299651273; Thu, 03 Dec 2026 04:07:31 -0800 (PST) X-Received: by 2002:a05:600c:848d:b0:4a1:c27d:e1a8 with SMTP id 5b1f17b1804b1-4bbe198418fmr31646225e9.10.1796299650665; Thu, 03 Dec 2026 04:07:30 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:153a:4c00:6468:7acf:febf:a046]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe005543esm77457735e9.5.2026.12.03.04.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 04:07:29 -0800 (PST) Date: Thu, 3 Dec 2026 07:07:27 -0500 From: "Michael S. Tsirkin" To: Tao Cui Cc: Jason Wang , Eugenio =?iso-8859-1?Q?P=E9rez?= , Stefan Hajnoczi , Stefano Garzarella , Bobby Eshleman , Mike Christie , Andrey Drobyshev , virtualization@lists.linux.dev, kvm@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, cuitao@kylinos.cn Subject: Re: [PATCH v3] vhost: account the per-device kernel allocations to memcg Message-ID: <20261203070711-mutt-send-email-mst@kernel.org> References: <20261203120106.2607381-1-cui.tao@linux.dev> X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261203120106.2607381-1-cui.tao@linux.dev> On Thu, Dec 03, 2026 at 08:01:06PM +0800, Tao Cui wrote: > From: Tao Cui > > Everything except the worker struct is allocated with plain GFP: > the per-vq iovec and log arrays at VHOST_SET_OWNER, the memory table > at VHOST_SET_MEM_TABLE whose size follows the user supplied region > count, the pending message nodes, the vhost_net/vhost_vsock device > structs with their fallback to vmalloc, the vhost-scsi device struct > and its vq arrays at open, the per-vq tag bitmap and command pools > sized by max_cmds and inline_sg_cnt, the target array at > VHOST_SCSI_SET_ENDPOINT, the vhost-vdpa device struct and vq array, > the per-asid allocations, the mapping file, and the GET_CONFIG buffer > sized by config.len. The worker has been accounted since the > vhost_task conversion. > > A container that can open /dev/vhost-net, /dev/vhost-vsock, > /dev/vhost-scsi or /dev/vhost-vdpa, which device plugins hand out > with passthrough, holds roughly 150KB of resident kernel memory per > device after SET_OWNER, and a vhost-scsi device holds a few hundred > KB more once its per-vq command pools are built. Charge the rest the > same way the worker already is. Per-command allocations in the > request path, the per-entry IOTLB map nodes, and vhost_iotlb_alloc(), > which drivers/vdpa also calls, stay uncharged. > > Acked-by: Michael S. Tsirkin > Acked-by: Bobby Eshleman > Signed-off-by: Tao Cui what tree is this against? error: sha1 information is lacking or useless (drivers/vhost/net.c). > --- > Changes in v3: > - extend the accounting to the vhost-scsi and vhost-vdpa backends, > whose allocations follow the same per-device pattern, per Stefano's > review on v2 > - rebased on next-20261202; the net/vsock/vhost.c hunks are identical > to v2, carrying Michael's and Bobby's acks from the earlier versions > Link to v2: https://lore.kernel.org/r/20261120054517.526275-1-cui.tao@linux.dev > > Changes in v2: > - rebased on next-20261118, where the vq->nheads allocation now uses > kmalloc_objs(); the flag addition follows the new form. No > functional change. Carries Michael's Acked-by from v1. > Link to v1: https://lore.kernel.org/r/20261106131829.3228926-4-cui.tao@linux.dev > --- > drivers/vhost/net.c | 14 ++++++++------ > drivers/vhost/scsi.c | 23 +++++++++++++---------- > drivers/vhost/vdpa.c | 14 ++++++++------ > drivers/vhost/vhost.c | 17 +++++++++++------ > drivers/vhost/vsock.c | 5 +++-- > 5 files changed, 43 insertions(+), 30 deletions(-) > > diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c > index 2adfe3678f76..36f76327610b 100644 > --- a/drivers/vhost/net.c > +++ b/drivers/vhost/net.c > @@ -249,7 +249,7 @@ vhost_net_ubuf_alloc(struct vhost_virtqueue *vq, bool zcopy) > /* No zero copy backend? Nothing to count. */ > if (!zcopy) > return NULL; > - ubufs = kmalloc_obj(*ubufs); > + ubufs = kmalloc_obj(*ubufs, GFP_KERNEL_ACCOUNT); > if (!ubufs) > return ERR_PTR(-ENOMEM); > atomic_set(&ubufs->refcount, 1); > @@ -302,7 +302,8 @@ static int vhost_net_set_ubuf_info(struct vhost_net *n) > if (!zcopy) > continue; > n->vqs[i].ubuf_info = > - kmalloc_objs(*n->vqs[i].ubuf_info, UIO_MAXIOV); > + kmalloc_objs(*n->vqs[i].ubuf_info, UIO_MAXIOV, > + GFP_KERNEL_ACCOUNT); > if (!n->vqs[i].ubuf_info) > goto err; > } > @@ -1340,17 +1341,18 @@ static int vhost_net_open(struct inode *inode, struct file *f) > struct xdp_buff *xdp; > int i; > > - n = kvmalloc_obj(*n, GFP_KERNEL | __GFP_RETRY_MAYFAIL); > + n = kvmalloc_obj(*n, GFP_KERNEL | __GFP_RETRY_MAYFAIL | > + __GFP_ACCOUNT); > if (!n) > return -ENOMEM; > - vqs = kmalloc_objs(*vqs, VHOST_NET_VQ_MAX); > + vqs = kmalloc_objs(*vqs, VHOST_NET_VQ_MAX, GFP_KERNEL_ACCOUNT); > if (!vqs) { > kvfree(n); > return -ENOMEM; > } > > queue = kmalloc_array(VHOST_NET_BATCH, sizeof(void *), > - GFP_KERNEL); > + GFP_KERNEL_ACCOUNT); > if (!queue) { > kfree(vqs); > kvfree(n); > @@ -1358,7 +1360,7 @@ static int vhost_net_open(struct inode *inode, struct file *f) > } > n->vqs[VHOST_NET_VQ_RX].rxq.queue = queue; > > - xdp = kmalloc_objs(*xdp, VHOST_NET_BATCH); > + xdp = kmalloc_objs(*xdp, VHOST_NET_BATCH, GFP_KERNEL_ACCOUNT); > if (!xdp) { > kfree(vqs); > kvfree(n); > diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c > index 8beeff06a7a7..ca1bbb95f4a5 100644 > --- a/drivers/vhost/scsi.c > +++ b/drivers/vhost/scsi.c > @@ -2020,18 +2020,19 @@ static int vhost_scsi_setup_vq_cmds(struct vhost_virtqueue *vq, int max_cmds) > if (svq->scsi_cmds) > return 0; > > - if (sbitmap_init_node(&svq->scsi_tags, max_cmds, -1, GFP_KERNEL, > + if (sbitmap_init_node(&svq->scsi_tags, max_cmds, -1, GFP_KERNEL_ACCOUNT, > NUMA_NO_NODE, false, true)) > return -ENOMEM; > svq->max_cmds = max_cmds; > > - svq->scsi_cmds = kzalloc_objs(*tv_cmd, max_cmds); > + svq->scsi_cmds = kzalloc_objs(*tv_cmd, max_cmds, GFP_KERNEL_ACCOUNT); > if (!svq->scsi_cmds) { > sbitmap_free(&svq->scsi_tags); > return -ENOMEM; > } > > - svq->upages = kzalloc_objs(struct page *, VHOST_SCSI_PREALLOC_UPAGES); > + svq->upages = kzalloc_objs(struct page *, VHOST_SCSI_PREALLOC_UPAGES, > + GFP_KERNEL_ACCOUNT); > if (!svq->upages) > goto out; > > @@ -2040,7 +2041,8 @@ static int vhost_scsi_setup_vq_cmds(struct vhost_virtqueue *vq, int max_cmds) > > if (vs->inline_sg_cnt) { > tv_cmd->sgl = kzalloc_objs(struct scatterlist, > - vs->inline_sg_cnt); > + vs->inline_sg_cnt, > + GFP_KERNEL_ACCOUNT); > if (!tv_cmd->sgl) { > pr_err("Unable to allocate tv_cmd->sgl\n"); > goto out; > @@ -2050,7 +2052,8 @@ static int vhost_scsi_setup_vq_cmds(struct vhost_virtqueue *vq, int max_cmds) > if (vhost_has_feature(vq, VIRTIO_SCSI_F_T10_PI) && > vs->inline_sg_cnt) { > tv_cmd->prot_sgl = kzalloc_objs(struct scatterlist, > - vs->inline_sg_cnt); > + vs->inline_sg_cnt, > + GFP_KERNEL_ACCOUNT); > if (!tv_cmd->prot_sgl) { > pr_err("Unable to allocate tv_cmd->prot_sgl\n"); > goto out; > @@ -2101,7 +2104,7 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs, > } > > len = sizeof(vs_tpg[0]) * VHOST_SCSI_MAX_TARGET; > - vs_tpg = kzalloc(len, GFP_KERNEL); > + vs_tpg = kzalloc(len, GFP_KERNEL_ACCOUNT); > if (!vs_tpg) { > ret = -ENOMEM; > goto out; > @@ -2380,7 +2383,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) > struct vhost_virtqueue **vqs; > int r = -ENOMEM, i, nvqs; > > - vs = kvzalloc_obj(*vs); > + vs = kvzalloc_obj(*vs, GFP_KERNEL_ACCOUNT); > if (!vs) > goto err_vs; > vs->inline_sg_cnt = vhost_scsi_inline_sg_cnt; > @@ -2389,15 +2392,15 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) > nvqs += VHOST_SCSI_VQ_IO; > > vs->old_inflight = kmalloc_objs(*vs->old_inflight, nvqs, > - GFP_KERNEL | __GFP_ZERO); > + GFP_KERNEL_ACCOUNT | __GFP_ZERO); > if (!vs->old_inflight) > goto err_inflight; > > - vs->vqs = kvzalloc_objs(*vs->vqs, nvqs); > + vs->vqs = kvzalloc_objs(*vs->vqs, nvqs, GFP_KERNEL_ACCOUNT); > if (!vs->vqs) > goto err_vqs; > > - vqs = kmalloc_objs(*vqs, nvqs); > + vqs = kmalloc_objs(*vqs, nvqs, GFP_KERNEL_ACCOUNT); > if (!vqs) > goto err_local_vqs; > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > index c729efd108d0..9a5bd454fe7b 100644 > --- a/drivers/vhost/vdpa.c > +++ b/drivers/vhost/vdpa.c > @@ -120,7 +120,7 @@ static struct vhost_vdpa_as *vhost_vdpa_alloc_as(struct vhost_vdpa *v, u32 asid) > if (max_iotlb_entries <= 0) > return NULL; > > - as = kmalloc_obj(*as); > + as = kmalloc_obj(*as, GFP_KERNEL_ACCOUNT); > if (!as) > return NULL; > > @@ -385,7 +385,7 @@ static long vhost_vdpa_get_config(struct vhost_vdpa *v, > return -EFAULT; > if (vhost_vdpa_config_validate(v, &config)) > return -EINVAL; > - buf = kvzalloc(config.len, GFP_KERNEL); > + buf = kvzalloc(config.len, GFP_KERNEL_ACCOUNT); > if (!buf) > return -ENOMEM; > > @@ -1159,7 +1159,7 @@ static int vhost_vdpa_va_map(struct vhost_vdpa *v, > !(vma->vm_flags & (VM_IO | VM_PFNMAP)))) > goto next; > > - map_file = kzalloc_obj(*map_file); > + map_file = kzalloc_obj(*map_file, GFP_KERNEL_ACCOUNT); > if (!map_file) { > ret = -ENOMEM; > break; > @@ -1521,7 +1521,7 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) > if (r) > goto err; > > - vqs = kmalloc_objs(*vqs, nvqs); > + vqs = kmalloc_objs(*vqs, nvqs, GFP_KERNEL_ACCOUNT); > if (!vqs) { > r = -ENOMEM; > goto err; > @@ -1689,7 +1689,8 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa) > (vdpa->ngroups > 1 || vdpa->nas > 1)) > return -EOPNOTSUPP; > > - v = kzalloc_obj(*v, GFP_KERNEL | __GFP_RETRY_MAYFAIL); > + v = kzalloc_obj(*v, GFP_KERNEL | __GFP_RETRY_MAYFAIL | > + __GFP_ACCOUNT); > if (!v) > return -ENOMEM; > > @@ -1711,7 +1712,8 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa) > v->dev.release = vhost_vdpa_release_dev; > v->dev.parent = &vdpa->dev; > v->dev.devt = MKDEV(MAJOR(vhost_vdpa_major), minor); > - v->vqs = kmalloc_objs(struct vhost_virtqueue, v->nvqs); > + v->vqs = kmalloc_objs(struct vhost_virtqueue, v->nvqs, > + GFP_KERNEL_ACCOUNT); > if (!v->vqs) { > r = -ENOMEM; > goto err; > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index 2d0238aacc6a..f62ff9e5aa24 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -526,10 +526,14 @@ static long vhost_dev_alloc_iovecs(struct vhost_dev *dev) > > for (i = 0; i < dev->nvqs; ++i) { > vq = dev->vqs[i]; > - vq->indirect = kmalloc_objs(*vq->indirect, UIO_MAXIOV); > - vq->log = kmalloc_objs(*vq->log, dev->iov_limit); > - vq->heads = kmalloc_objs(*vq->heads, dev->iov_limit); > - vq->nheads = kmalloc_objs(*vq->nheads, dev->iov_limit); > + vq->indirect = kmalloc_objs(*vq->indirect, UIO_MAXIOV, > + GFP_KERNEL_ACCOUNT); > + vq->log = kmalloc_objs(*vq->log, dev->iov_limit, > + GFP_KERNEL_ACCOUNT); > + vq->heads = kmalloc_objs(*vq->heads, dev->iov_limit, > + GFP_KERNEL_ACCOUNT); > + vq->nheads = kmalloc_objs(*vq->nheads, dev->iov_limit, > + GFP_KERNEL_ACCOUNT); > if (!vq->indirect || !vq->log || !vq->heads || !vq->nheads) > goto err_nomem; > } > @@ -2052,7 +2056,8 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m) > return -E2BIG; > if (max_iotlb_entries <= 0) > return -EINVAL; > - newmem = kvzalloc_flex(*newmem, regions, mem.nregions); > + newmem = kvzalloc_flex(*newmem, regions, mem.nregions, > + GFP_KERNEL_ACCOUNT); > if (!newmem) > return -ENOMEM; > > @@ -3414,7 +3419,7 @@ EXPORT_SYMBOL_GPL(vhost_disable_notify); > struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type) > { > /* Make sure all padding within the structure is initialized. */ > - struct vhost_msg_node *node = kzalloc_obj(*node); > + struct vhost_msg_node *node = kzalloc_obj(*node, GFP_KERNEL_ACCOUNT); > if (!node) > return NULL; > > diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c > index 03a3b833640d..b31262a2b11f 100644 > --- a/drivers/vhost/vsock.c > +++ b/drivers/vhost/vsock.c > @@ -719,11 +719,12 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file) > /* This struct is large and allocation could fail, fall back to vmalloc > * if there is no other way. > */ > - vsock = kvmalloc_obj(*vsock, GFP_KERNEL | __GFP_RETRY_MAYFAIL); > + vsock = kvmalloc_obj(*vsock, GFP_KERNEL | __GFP_RETRY_MAYFAIL | > + __GFP_ACCOUNT); > if (!vsock) > return -ENOMEM; > > - vqs = kmalloc_objs(*vqs, ARRAY_SIZE(vsock->vqs)); > + vqs = kmalloc_objs(*vqs, ARRAY_SIZE(vsock->vqs), GFP_KERNEL_ACCOUNT); > if (!vqs) { > ret = -ENOMEM; > goto out;