Patch "libbpf: Unmap rings when umem deleted" has been added to the 5.15-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    libbpf: Unmap rings when umem deleted

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     libbpf-unmap-rings-when-umem-deleted.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 58608c982b62cff7a8ec49a1a04f95c2ddb7d348
Author: lic121 <lic121@xxxxxxxxxxxxxxx>
Date:   Tue Mar 1 13:26:23 2022 +0000

    libbpf: Unmap rings when umem deleted
    
    [ Upstream commit 9c6e6a80ee741adf6cb3cfd8eef7d1554f91fceb ]
    
    xsk_umem__create() does mmap for fill/comp rings, but xsk_umem__delete()
    doesn't do the unmap. This works fine for regular cases, because
    xsk_socket__delete() does unmap for the rings. But for the case that
    xsk_socket__create_shared() fails, umem rings are not unmapped.
    
    fill_save/comp_save are checked to determine if rings have already be
    unmapped by xsk. If fill_save and comp_save are NULL, it means that the
    rings have already been used by xsk. Then they are supposed to be
    unmapped by xsk_socket__delete(). Otherwise, xsk_umem__delete() does the
    unmap.
    
    Fixes: 2f6324a3937f ("libbpf: Support shared umems between queues and devices")
    Signed-off-by: Cheng Li <lic121@xxxxxxxxxxxxxxx>
    Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20220301132623.GA19995@vscode.7~
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
index e9b619aa0cdf..a27b3141463a 100644
--- a/tools/lib/bpf/xsk.c
+++ b/tools/lib/bpf/xsk.c
@@ -1210,12 +1210,23 @@ int xsk_socket__create(struct xsk_socket **xsk_ptr, const char *ifname,
 
 int xsk_umem__delete(struct xsk_umem *umem)
 {
+	struct xdp_mmap_offsets off;
+	int err;
+
 	if (!umem)
 		return 0;
 
 	if (umem->refcount)
 		return -EBUSY;
 
+	err = xsk_get_mmap_offsets(umem->fd, &off);
+	if (!err && umem->fill_save && umem->comp_save) {
+		munmap(umem->fill_save->ring - off.fr.desc,
+		       off.fr.desc + umem->config.fill_size * sizeof(__u64));
+		munmap(umem->comp_save->ring - off.cr.desc,
+		       off.cr.desc + umem->config.comp_size * sizeof(__u64));
+	}
+
 	close(umem->fd);
 	free(umem);
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux