[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH RFC 1/3] xen/privcmd: replace kcalloc() by kvcalloc() when allocating empty pages


  • To: Juergen Gross <jgross@xxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 22 Sep 2021 12:16:35 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Ihy5AqkbKQlh/sKYZgTSszLHYrjLcDDqhUqK4o2XEtI=; b=fKw+T/6jhwEJrkEv7XmjK5n/vgkkuOFVrw9yDrJ/4vDywMqCizGc8v8w6WPbkZu1AzvQ3ekVFCCqqZsqBwR+8hx8ZvgjDER72MLaPXJW0eR/ludwFpBpsndtZgWoGhI4iNIHUZvn5HZLTjqd3ymBKUm9yMGXjHwilmscaVIfbxNKyPqvaqhzM3ruT2Edt/r3Hvl1fM0BPLRAODS3yrDea6Vi1TUPOGfO+BvJGMAG1lL/pNGfTyZ4LKFAZNTk00UAm3Sz5vkcYSZB4SqGsJDRzyvfQKRM4N7+CrrF+Ogk17W0mZI5rPajDehNlwUdHhRAEnlSv+qGQskfoz6X8Ivasg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L5VQZxg717y8Nyolf0kqnaz7jbvhKbq+SsbF4PQMpjjxSb+wtykIjxpYc8yYcvO5oUR/uh/PNzQDGMiGI3COZaqYcpSgngYK7xe2FK7ujqq41hbfaHfzM0SFdT71ZLlssFWL70rdeUhA+hx9In3JVPbicusdksQV5jC/rOAdNHIO8futks2m6RQPz/JQ90HLr1PDBqZB6QMr3dDoXqF3opWPZUFVXsls/Oy9HxxSDer6ecT5hqwCENsGYpTRNoDadTeu0LGwDmMcKKZ4Qw55qaQRg1AvtpqxMQ4Idyxj1Qy+1zZ/vYCZXC69BpOweTvoDLorHrkQIAhxbZ/3J0Uk4w==
  • Authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=suse.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, lkml <linux-kernel@xxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 22 Sep 2021 10:16:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Osstest has been suffering test failures for a little while from order-4
allocation failures, resulting from alloc_empty_pages() calling
kcalloc(). As there's no need for physically contiguous space here,
switch to kvcalloc().

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
RFC: I cannot really test this, as alloc_empty_pages() only gets used in
     the auto-translated case (i.e. on Arm or PVH Dom0, the latter of
     which I'm not trusting enough yet to actually start playing with
     guests).

There are quite a few more kcalloc() where it's not immediately clear
how large the element counts could possibly grow nor whether it would be
fine to replace them (i.e. physically contiguous space not required).

I wasn't sure whether to Cc stable@ here; the issue certainly has been
present for quite some time. But it didn't look to cause issues until
recently.

--- a/drivers/xen/privcmd.c
+++ b/drivers/xen/privcmd.c
@@ -420,7 +420,7 @@ static int alloc_empty_pages(struct vm_a
        int rc;
        struct page **pages;
 
-       pages = kcalloc(numpgs, sizeof(pages[0]), GFP_KERNEL);
+       pages = kvcalloc(numpgs, sizeof(pages[0]), GFP_KERNEL);
        if (pages == NULL)
                return -ENOMEM;
 
@@ -428,7 +428,7 @@ static int alloc_empty_pages(struct vm_a
        if (rc != 0) {
                pr_warn("%s Could not alloc %d pfns rc:%d\n", __func__,
                        numpgs, rc);
-               kfree(pages);
+               kvfree(pages);
                return -ENOMEM;
        }
        BUG_ON(vma->vm_private_data != NULL);
@@ -912,7 +912,7 @@ static void privcmd_close(struct vm_area
        else
                pr_crit("unable to unmap MFN range: leaking %d pages. rc=%d\n",
                        numpgs, rc);
-       kfree(pages);
+       kvfree(pages);
 }
 
 static vm_fault_t privcmd_fault(struct vm_fault *vmf)




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.