virtio: Do not drop __GFP_HIGH in alloc_indirect
PATCH 1/1 virtio: Do not drop __GFP_HIGH in alloc_indirect
From: Michal Hocko <[email protected]>
b92b1b89a33c ("virtio: force vring descriptors to be allocated from lowmem") tried to exclude highmem pages for descriptors so it cleared __GFP_HIGHMEM from a given gfp mask. The patch also cleared __GFP_HIGH which doesn't make much sense for this fix because __GFP_HIGH only controls access to memory reserves and it doesn't have any influence on the zone selection. Some of the call paths use GFP_ATOMIC and dropping __GFP_HIGH will reduce their changes for success because the lack of access to memory reserves.
---
Hi,
I have stumbled over this code while looking at other issue [1]. I think that using __GFP_HIGH simply got there because of its confusing name. It doesn't have anything to do with the highmem zone.
The patch is based on the current linux-next.
I think that clearing __GFP_HIGHMEM is bogus in the current code because all code paths either use GFP_KERNEL or GFP_ATOMIC and those do not fall back to the highmem zone but I have kept it because clearing the flag cannot be harmful.
[1] http://lkml.kernel.org/r/87h9k4kzcv.fsf%40yhuang-dev.intel.com
drivers/virtio/virtio_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/virtio_ring.c +1 -1
@@ -110,7 +110,7 @@ static struct vring_desc *alloc_indirect(struct virtqueue *_vq,* otherwise virt_to_phys will give us bogus addresses in the * virtqueue. */ - gfp &= ~(__GFP_HIGHMEM | __GFP_HIGH); + gfp &= ~__GFP_HIGHMEM; desc =kmalloc (total_sg *sizeof (struct vring_desc ), gfp);if (!desc)
Signature · 1 line
2.6.2
Quoted 25 lines · Michal Hocko
From: Michal Hocko <[email protected]>
b92b1b89a33c("virtio: force vring descriptors to be allocated from lowmem") tried to exclude highmem pages for descriptors so it cleared__GFP_HIGHMEMfrom a given gfp mask. The patch also cleared__GFP_HIGHwhich doesn't make much sense for this fix because__GFP_HIGHonly controls access to memory reserves and it doesn't have any influence on the zone selection. Some of the call paths useGFP_ATOMICand dropping__GFP_HIGHwill reduce their changes for success because the lack of access to memory reserves.Signed-off-by Michal Hocko <[email protected]>---
Hi,
I have stumbled over this code while looking at other issue [1]. I think that using__GFP_HIGHsimply got there because of its confusing name. It doesn't have anything to do with the highmem zone.The patch is based on the current linux-next.
I think that clearing
__GFP_HIGHMEMis bogus in the current code because all code paths either useGFP_KERNELorGFP_ATOMICand those do not fall back to the highmem zone but I have kept it because clearing the flag cannot be harmful.
Quoted 4 lines
[1] http://lkml.kernel.org/r/87h9k4kzcv.fsf%40yhuang-dev.intel.com
drivers/virtio/virtio_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks for cleaning this up:
Will
Quoted 16 lines
drivers/virtio/virtio_ring.c +1
-1@@ -110,7 +110,7 @@ static struct vring_desc *alloc_indirect(struct virtqueue *_vq,* otherwise virt_to_phys will give us bogus addresses in the * virtqueue. */ - gfp &= ~(__GFP_HIGHMEM | __GFP_HIGH); + gfp &= ~__GFP_HIGHMEM; desc =kmalloc (total_sg *sizeof (struct vring_desc ), gfp);if (!desc)Signature · 1 line
2.6.2
Quoted 11 lines · Michal Hocko
From: Michal Hocko <[email protected]>
b92b1b89a33c("virtio: force vring descriptors to be allocated from lowmem") tried to exclude highmem pages for descriptors so it cleared__GFP_HIGHMEMfrom a given gfp mask. The patch also cleared__GFP_HIGHwhich doesn't make much sense for this fix because__GFP_HIGHonly controls access to memory reserves and it doesn't have any influence on the zone selection. Some of the call paths useGFP_ATOMICand dropping__GFP_HIGHwill reduce their changes for success because the lack of access to memory reserves.
Quoted 1 line
Signed-off-by Michal Hocko <[email protected]>
It also has been tested by Ying Huang and found to have fixed a page allocation failure problem in 4.4-rc3 in the Intel 0-day testing infrastructure.
Signature · 2 lines
Mel Gorman SUSE Labs
Quoted 11 lines · Michal Hocko
From: Michal Hocko <[email protected]>
b92b1b89a33c("virtio: force vring descriptors to be allocated from lowmem") tried to exclude highmem pages for descriptors so it cleared__GFP_HIGHMEMfrom a given gfp mask. The patch also cleared__GFP_HIGHwhich doesn't make much sense for this fix because__GFP_HIGHonly controls access to memory reserves and it doesn't have any influence on the zone selection. Some of the call paths useGFP_ATOMICand dropping__GFP_HIGHwill reduce their changes for success because the lack of access to memory reserves.
Quoted 1 line
Signed-off-by Michal Hocko <[email protected]>
It also has been tested by Ying Huang and found to have fixed a page allocation failure problem in 4.4-rc3 in the Intel 0-day testing infrastructure.
Signature · 2 lines
Mel Gorman SUSE Labs