kmalloc

What is the use of GFP_USER flag in kmalloc?

孤人 提交于 2019-12-30 11:28:05
问题 As far as I understand, the use in the GFP_USER flag (in the call to kmalloc ) is used to allocate memory for user space. Does it means that the allocated page are in kernel space, which are accessible to user? Does these pages required to be mmapp 'ed in user space or the address is directly accessible to user. If they need to mmapp then what is difference between GFP_USER and GFP_KERNEL ? 回答1: Brief explanation can be found in kernel sources: GFP_KERNEL is typical for kernel-internal

How can kmalloc return a physical address greater than the size of the physical address?

与世无争的帅哥 提交于 2019-12-12 03:57:18
问题 I am allocating a block of memory with kmalloc in a device driver in Linux. The address that I get is 0xffff880000180000 . I am using an IvyBridge processor with a 46-bit physical address space. That means that the CPU doesn't have more than 46 addressing pins, so it can't access any address above 0x00003fffffffffff . The address I'm getting is obviously greater than that, as it has bit 47 set. Assuming that kmalloc returns a physical pointer (that is, a pointer where the virtual, linear and

Kmalloc Alignment

谁说胖子不能爱 提交于 2019-12-11 07:28:11
问题 Lets say I allocate with kmalloc an array of uint64_t (and lets assume the size of the array is 32kB). I have the following questions : 1) Is the array guaranteed to be page aligned ? 2) Is the array guaranteed to be cache / block aligned ? 3) Is there no guarantee at all ? When I allocate the array , and i use virt_to_phys to get the physical address of the array i am gettign physical addresses like 00000040142d5c00 and virtual addresses like fffffe07df400000 Is there any chance that i will

Why am I getting a high address when I use kmalloc with GFP_DMA in Linux?

二次信任 提交于 2019-12-07 15:37:40
问题 I am writing a device driver for a DMA device in Linux. In Linux Device Drivers, Chapter 15, it says: For devices with this kind of limitation, memory should be allocated from the DMA zone by adding the GFP_DMA flag to the kmalloc or get_free_pages call. When this flag is present, only memory that can be addressed with 24 bits is allocated. Alternatively, you can use the generic DMA layer (which we discuss shortly) to allocate buffers that work around your device’s limitations I am calling

Why am I getting a high address when I use kmalloc with GFP_DMA in Linux?

回眸只為那壹抹淺笑 提交于 2019-12-05 18:28:56
I am writing a device driver for a DMA device in Linux. In Linux Device Drivers, Chapter 15 , it says: For devices with this kind of limitation, memory should be allocated from the DMA zone by adding the GFP_DMA flag to the kmalloc or get_free_pages call. When this flag is present, only memory that can be addressed with 24 bits is allocated. Alternatively, you can use the generic DMA layer (which we discuss shortly) to allocate buffers that work around your device’s limitations I am calling kmalloc like this: physical_pointer0 = kmalloc(number_of_bytes, GFP_DMA); and printing the result like

What is the use of GFP_USER flag in kmalloc?

最后都变了- 提交于 2019-12-01 00:40:25
As far as I understand, the use in the GFP_USER flag (in the call to kmalloc ) is used to allocate memory for user space. Does it means that the allocated page are in kernel space, which are accessible to user? Does these pages required to be mmapp 'ed in user space or the address is directly accessible to user. If they need to mmapp then what is difference between GFP_USER and GFP_KERNEL ? Brief explanation can be found in kernel sources : GFP_KERNEL is typical for kernel-internal allocations. The caller requires ZONE_NORMAL or a lower zone for direct access but can direct reclaim. GFP_USER

What is the difference between vmalloc and kmalloc?

断了今生、忘了曾经 提交于 2019-11-26 16:56:21
I've googled around and found most people advocating the use of kmalloc , as you're guaranteed to get contiguous physical blocks of memory. However, it also seems as though kmalloc can fail if a contiguous physical block that you want can't be found. What are the advantages of having a contiguous block of memory? Specifically, why would I need to have a contiguous physical block of memory in a system call ? Is there any reason I couldn't just use vmalloc ? Finally, if I were to allocate memory during the handling of a system call, should I specify GFP_ATOMIC ? Is a system call executed in an

What is the difference between vmalloc and kmalloc?

寵の児 提交于 2019-11-26 06:05:09
问题 I\'ve googled around and found most people advocating the use of kmalloc , as you\'re guaranteed to get contiguous physical blocks of memory. However, it also seems as though kmalloc can fail if a contiguous physical block that you want can\'t be found. What are the advantages of having a contiguous block of memory? Specifically, why would I need to have a contiguous physical block of memory in a system call ? Is there any reason I couldn\'t just use vmalloc ? Finally, if I were to allocate