w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Is the memory address returned by malloc/calloc from virtual address space?
All addresses you see in user space applications are virtual addresses. Physical addresses are only of concern to the kernel. The mapping from virtual to physical addresses is complex, given that: Not all virtual addresses have physical addresses at all. (For instance, pages that are unmapped, lazily zero-filled, or swapped out have no physical address.) Physical addresses may change without warning (e.g, if a page is swapped out and back in, or if a shared page is copied). Outside of some very unusual situations (mostly having to do with messing around with hardware), you should not care about physical addresses.

Categories : C

Virtual address space vs virtual memory
From Wikipedia articles for virtual memory and virtual address space: Virtual memory is a memory management technique developed for multitasking kernels. Virtual address space is a memory mapping mechanism available in modern operating systems. So the answer is: yes, these are quite different terms. Although they are related.

Categories : Linux

Why mmap fails when trying to map Upper BIOS memory to virtual address space
Per your comment that size is 36: size must be a multiple of the system page size. See C - why I cannot mmap a small (256UL or smaller) size of memory?

Categories : C

What is the linux command line to check kernel space and User space Memory used
Try: sudo slabtop or sudo cat /proc/slabinfo These should give you enough information to estimate the total kernel memory consumption. You can read more info about kernel and userspace memory here.

Categories : Linux

virtual to physical address conversion in linux kernel
It's not really "assembly" as there is no instruction in this macro per se. It's just a macro which inserts instr (an instruction passed to the macro) which has one input operand from, one immediate (constant) input operand type and a output operand to. There is also the part between pushsection and popsection which records in a specific binary section pv_table the address of this instruction. That allows the kernel to find these places in its code if it wishes to. The last part is the asm constraints and operands. It lists what the compiler will replace %0, %1 and %2 with. %0 is the first listed ("=r"(to)), it means that %0 will be any general purpose register, that is an output operand that will be stored in the macro argument to. The other 2 are similar except they're input opera

Categories : Linux

High non-mapped virtual memory for mongodb
I investigated and had some strong indications that the issue was related to using rockmongo. I launched a private support ticket with 10gen and they found that the issue was indeed rockmongo related. Apparently it uses a lot of eval() calls which spawn a server side V8 javascript engine requiring a lot of memory. I filed a bug-report with rockmongo.

Categories : Mongodb

Which address space is occupied by the kernel in 64 bit linux
On a 64-bit Linux all 64-bit addresses with the highest order bit set to 1 are reserved for the kernel. In other words, the top half of the virtual address space. See http://en.wikipedia.org/wiki/X86-64#Virtual_address_space_details

Categories : C

Find memory address in hex string in kernel module
I am not familiar with linux kernel. In the while statement, when you go into the first if statement, the debug then point to ffffffff8134efa8 ffffffff8134efa8: 65 48 81 04 25 7c 13 addq $0x1000,%gs:0x1137c # debug point here ffffffff8134efaf: 01 00 00 10 00 00 the next statement unsigned long *do_debug = (unsigned long *)(0xffffffff00000000 | *((unsigned long *)(debug))); will get this result. do_debug = (unsigned long *)(0xffffffff00000000 | 0x01137c2504814865) = 0xffffffff04814865 if you want to get the do_debug address, you should do this: if( (*(debug) == 0xe8) && (*(debug + 1) == 0x61) && (*(debug + 2) == 0x07) && (*(debug + 3) == 0x00) && (*(debug + 4) == 0x00) ){ //debug += 5; uint32_t offset = ntohl(*(unsigned int *)(de

Categories : C

why there are two virtual destructor in the virtual table and where is address of the non-virtual function (gcc4.6.3)
The address of the non-virtual member function, well you said it, it's not virtual which means it doesn't need to be in the virtual table. Why? Well it doesn't depend on the runtime type of the object, only the static type meaning the compiler can figure out at compile time which function to call so the call is resolved then instead of using late binding during execution. The function itself is in the code section somewhere and so at compile time the functions address is inserted at the call site directly. Ok now onto the fun stuff. I did some digging around in the visual studio watch list and here is what I found: |---------------------------| | Derive | |---------------------------| | vtable ptr for Base1 (+0) | | Base1::a (+4) | |------------------------

Categories : C++

Linux Kernel - stoping a running kernel timer from user space
Have you considered trying netlink? It's a powerful method for user-to-kernel (or process-to-process) communication which both simple and lightweight.

Categories : Linux

Are Java threads created in user space or kernel space?
Java threads are "user" threads, but under the hood, the Java Virtual Machine is using kernel threads and delegating the user threads CPU time on each kernel thread in its kernel thread pool. See this question for a better explanation. It seems that threading is JVM-vendor specific, and my understanding might not hold for all JVM implementations.

Categories : Java

Hashcode is memory address or integer number of content of memory address?
simply saying, hashcode is a number that is returned by hash function used to map variable length data to fixed lenght. You can find good information about hashcodes here http://www.thejavageek.com/2013/06/27/what-are-hashcodes/ and for hashcode in java programming see following link http://www.thejavageek.com/2013/06/28/significance-of-equals-and-hashcode/

Categories : Java

how is virtual address translated to its physical address on backing store?
This is OS-specific, but many implementations share logic with memory-mapped file features (so that anonymous pages actually are memory-mapped views of the pagefile, flagged so that the content can be discards at unmapping instead of flushed). For Windows, much of this is documented here, on the CreateFileMapping page

Categories : C

.NET application memory usage - high unused .NET and unmanaged memory and fragmentation
As Alex already pointed out a very nice explanation of the problem class large object heap fragmentation is found here: https://www.simple-talk.com/dotnet/.net-framework/the-dangers-of-the-large-object-heap/ The problem is well known in the .NET FX Dev Team and continuously been worked at. There is a good chance that the symptoms fade off using more recent FX releases. Starting with .NET 4.5.1 there will be a GC method call to even compact the LOH: http://blogs.msdn.com/b/mariohewardt/archive/2013/06/26/no-more-memory-fragmentation-on-the-large-object-heap.aspx However, finding the root cause of the LOHF would be way more efficient than just wiping it of the heap wasting tons of ms's Let me know, if you need further details how to isolate such effects. Seb

Categories : Dotnet

Memory mapping size control in virtual memory
Firstly understand that the heap and stack themselves consist of memory maps. Each userland process has a table of memory maps, and this is how it interacts with the kernel memory manager. Memory maps have different configurations and features. Consult the mmap(2) man page for a list of settings. With a file-backed mmap, the kernel manages the caching of the file in units of page size (4096 bytes) in a highly optimized way. If you are going to read a file sequentially, then a memory map doesn't have any advantage. If you are going to read the file in random access, then a memory mapped file may be more performant (usually is) as the kernel applies a caching strategy automatically for you, with CPU support on most platforms. Roughly speaking the file is divided into 4096 byte blocks

Categories : Linux

Virtual memory sections and memory mapping area
Using memory mapping for IPC works by mapping the same range of physical memory into two or more virtual address ranges in different processes. This works for communication because both processes are using the exact same memory cells (although they might "see" them differently, at different addresses). You change a value in one mapping, and it is instantly visible in the other mapping in a different process because it is the very same memory. Every process has its own independent stack and heap. The OS does not care about that at all, it only cares about pages. The heap and the stack are things that are implemented by the application (via the runtime). When you call a function like malloc, the allocator in the runtime either returns a block that it already had reserved earlier or one that

Categories : Linux

Address and Address Range Syntax search memory when using windbg to do debug
The L refers to the length of the range to search so using 0012ff40 as starting range, plus 32 bytes would give end address of 0012ff5f (remember it includes the starting address). To answer your second part the -d flag tells WinDbg the type of the object, in this case DWORD which will be 32-bit unsigned integer

Categories : Debugging

Priorities in kernel space
Let me try to answer your questions or make your question clearer. Hardware handler is running in interrupt context. Of course, one hardware handler is divided to two parts: a smaller but critical one which is executed in interrupt context, while the other one is bigger one which can be defered and is executed in soft-irq context. While "the /proc file handler"(you called it) is executed in user-process context. When you access /proc file, the handler is triggered and executed. In hardware interrupt context, sometime, the local hardware interrupt is disabled. In the soft-irq context, sometime, the BH is disable or kernel preempt is disable. That is to say, in interrupt context, sometime, the schedule does not happen. So based on this, I can say that priority of the "/proc file handler"

Categories : Linux

Kernel is not being loaded at correct address
Well, everything seems to be OK, so the problem is maybe somewhere else. (BTW, it is not necessary to STC before int 13h, but this can't be a reason for the described problem). So, I would suggest to try to use the Bochs debugger and inserting int3 breakpoints on the key positions in your source - for example before the kernel read operations and just before the far jump (where you can check what is loaded on $1000:0000 Another note, also not very important, is the value of SP. 7c00h is somehow not usual value for SP, but anyway it is not obvious problem. Also, the kernel code has to be checked one more time.

Categories : Assembly

How do I know if an address in Linux kernel is readable or not?
The copy_from_user and related functions get the address from some untrusted user space program; they protect against invalid addresses by installing a special exception handler. (See this answer for details.) You could do the same, but this would protect only against addresses that the kernel has marked as invalid in the page tables; accesses to some random device's MMIO range might have unpredictable results. If you want to search for something in some BIOS ROM, remap that memory like any other PCI resource. If you want to search for something in main memory, you could use some function like ioremap or kmap to get a valid virtual address for a specific physical address.

Categories : Linux

Memory mapping, virtual and physical memory in C++
In linux you can used the shared memory.The shared memory is a mechanism which allow two process access a same area of memory, it is a kind of IPC method. You can find some more details here http://en.wikipedia.org/wiki/Shared_memory.

Categories : C++

How to remove() a file in the kernel space?
As per my discussion with an advanced kernel developer ,I came to learn that it is not possible to delete files in a kernel module.So as per my requirement i have modified my signalling mechanism so that it now includes remaking proc entries in the system.Thanks @Basile

Categories : Linux

How Callback is maintained from Userspace to Kernel Space
First of all, this driver, gpio_wdt.c, doesn't seem to exist in the mainline kernel as of this date, so it's hard to comment it. Sysfs (usually mounted at /sys) is actually very easy to use. This is a great example of how to create Sysfs attributes. Basically, you create attributes (will become the Sysfs file names) and register them with two defined operations (callbacks): store and show, which are the equivalent of resp. write and read. The show callback is called everytime the Sysfs file (attribute) is read and store when it's written. When writing a device driver that belongs to an existing class (most likely your situation), you will rarely need to do that yourself. This is because the standard Linux device classes already have a working set of Sysfs attributes that your driver will

Categories : C

Shutdown (embedded) linux from kernel-space
The most general way would be for your driver to invoke shutdown as a userspace helper: static const char * const shutdown_argv[] = { "/sbin/shutdown", "-h", "-P", "now", NULL }; call_usermodehelper(shutdown_argv[0], shutdown_argv, NULL, UMH_NO_WAIT); (Presuming you have a /sbin/shutdown binary installed). This will shut userspace down cleanly, unmount filesystems and then request the kernel shutdown and power off. However, you may be able to do better than this - for example if you can guarantee that there's no disk filesystems mounted read/write, you could tell a kernel thread to invoke the kernel_power_off() function (it shouldn't be done from interrupt context).

Categories : Linux

Is there a function similar to qsort() to be used in kernel space?
That's a good question. The functionsort() in lib/sort.c does the job, but it's a heap sort, you can learn more about this choice in lib/sort.c

Categories : C

How to send a "signal" from kernel module to user-space application?
Use the netlink. Netlink socket is a special IPC used for transferring information between kernel and user-space processes. It provides a full-duplex communication link between the two by way of standard socket APIs for user-space processes and a special kernel API for kernel modules. Netlink socket uses the address family AF_NETLINK, as compared to AF_INET used by TCP/IP socket. Each netlink socket feature defines its own protocol type in the kernel header file include/linux/netlink.h.

Categories : Linux

kernel driver reading ok from user space, but writing back is always 0
Your read function always returns 0 because you are returning retval, and not the count of bytes read. As long as the copy_to_user() call always succeeds, retval will always be 0. Instead, as long as copy_to_user() succeeds, you should return the number of bytes actually written to user space. This documentation states that copy_to_user() returns the total number of bytes that it was unable to copy. As an aside, you are ignoring the value of count. It is very possible that the user is requesting less data than you have available in your buffer. You should never ignore count. Now you have the problem where your function never returns a 0. Returning a 0 is important because is tells the user application that there is no more data available for reading and the user application should c

Categories : Linux

Azure VIP (Virtual IP Address)
Does Production Slot VIP gets changed when we do VIP SWAP? When a customer swaps the VIP between a stage and production deployment in a single hosted service, both deployment VIPs are persisted. Does new deployment changes VIP? Throughout the lifetime of a deployment, the VIP assigned will not change, regardless of the operations on the deployment, including updates, reboots, and reimaging the OS. On what sort of scenarios does the VIP changes? When a deployment is deleted, the VIP associated with that deployment will return to the pool and be re-assigned accordingly, even if the hosted service is not deleted. If I delete the Staging Slot and redeploy and perform VIP swap then will it generate new VIP? Since Staging is also a deployment, I think deletion of Staging Slot would retu

Categories : Azure

Genymotion didn't get an ip address from virtual box
Try downgrading to Virtual Box 4.2.18, if you are using 4.3.X. I had a similar situation to yours. I was using Genymotion 1.3.0 on Win7, with latest Virtual Box 4.3.2. Genymotion broke down after a computer shutdown, and never worked again. I kinda stumbled onto this solution. After downgrading, Genymotion survived one shutdown now.

Categories : Android

Windows kernel memory protection
Assuming you are talking about x86 and x64 architectures. Memory protection is achieved using the paging system. Each page table entry on an x86/x64 CPU has a bit to indicate whether it is a user or supervisor page. Accesses to supervisor pages are only permitted for code running with CPL<3, whereas accesses to non supervisor pages are possible regardless of CPL. CPL is the "Current Privilege Level" which is sometimes referred to as Ring. Windows only uses two rings, although the CPU implements 4. Ring 0 is the CPU mode in which what Windows refers to as "kernel mode" runs. Ring 3 is the CPU mode in which "User mode" runs. Since code running at CPL=3 cannot access supervisor pages, this is how memory protection is implemented. The answer for ARM is likely to be similar, but different

Categories : Windows

how is a memory barrier in linux kernel is used
From the section of the document titled "WHAT MAY NOT BE ASSUMED ABOUT MEMORY BARRIERS?": There is no guarantee that any of the memory accesses specified before a memory barrier will be complete by the completion of a memory barrier instruction; the barrier can be considered to draw a line in that CPU's access queue that accesses of the appropriate type may not cross. and There is no guarantee that a CPU will see the correct order of effects from a second CPU's accesses, even if the second CPU uses a memory barrier, unless the first CPU also uses a matching memory barrier (see the subsection on "SMP Barrier Pairing"). What memory barriers do (in a very simplified way, of course) is make sure neither the compiler nor in-CPU hardware perform any

Categories : Linux

Apache virtual host for browsing with IP address
I am personally using this one for IP Vhost NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin contact@steelbrain.com.pk DocumentRoot /var/www/ipbased/ ServerName 192.168.1.1 ServerAlias 192.168.1.1 192.168.1.2 </VirtualHost>

Categories : Apache

Patch / replace linux kernel in memory
Take a look at this link It's for a project called Ksplice that allows one to patch a running kernel. At one point this code was open, but Oracle bought it... So they may have closed it up and made it cost money. If that's the case, look around and see if you can find the formerly open code in the wild...

Categories : Linux

How Linux kernel decide to which memory zone to use?
For every memory allocation request (for eg via kmalloc), based on the flags passed to the function,kernel selects the memory zone. these requests internally triggers the kernel function alloc_pages(). zonelist is an argument that gets passed to alloc_pages(), that Points to a zonelist data structure describing, in order of preference, the mem- ory zones suitable for the memory allocation. refer the memory management chapter in book Understanding the Linux kernel

Categories : Linux

CUDA Dynamic memory allocation in kernel
Concerning point #2, you would need something like C++'s realloc(), which, as long as I know, is not supported by CUDA. You can write your own realloc() according to this post CUDA: Using realloc inside kernel but I do not know how efficient will be this solution. Alternatively, you should pre-allocate a "large" amount of global memory to be able to account for the worst case memory occupation scenario.

Categories : Multithreading

.NET - high memory usage by clr.dll and native heaps
Use !dumpheap -stat at each stage. You may be able to find which type is getting increased drastically at each stage. On those objects use !gcroot <"addr"> to find which object is holding it from getting garbage collected.

Categories : Dotnet

Azure Virtual Machine low disk space
You cannot increase your os disk size. Not sure when you created your Virtual Machine. I know that a long time ago the size was set at (I believe) 30GB, and now the os disks should be around 127GB. You may want to check what size the OS disk is. I'm not sure what chewed up your OS disk space except maybe some type of temporary os storage.

Categories : Azure

Tomcat process killed by Linux kernel after running out of swap space; don't get any JVM OutOfMemory error
You probably have other processes on the same computer that also use memory. It looks like your java process reaches around 5.3GB before the machine is desperately out of RAM and swap. (Other processes are then probably using 12GB-5.3GB = 6.7GB) So your linux kernel sacrifices your java process to keep other processes running. The java memory limit is never reached so you're not getting an OutOfMemoryException. Consider all the processes you need running on the entire machine, and adjust your Xmx setting accordingly (enough to leave room for all the other processes). Perhaps 5gb? In any case, counting of OutOfMemoryExceptions being delivered is a pretty bad code smell. If I recall correctly, getting even a single OutOfMemoryException can leave the JVM in an "all-bets-are-off" state and

Categories : Java

Virtual Host not serving up correct website with same IP address
You can create a virtual network interface and add another IP to the second virtual host / server name: <VirtualHost 123.123.123.123:80> ServerAdmin webmaster@localhost ServerName myNEWsite DocumentRoot "/home/webmaster/development/myNEWsite.co.uk/user/htdocs" ErrorLog "/home/webmaster/development/myNEWsite.co.uk/logfiles/error_log" CustomLog "/home/webmaster/development/myNEWsite.co.uk/logfiles/access_log" common <Directory "/home/webmaster/development/myNEWsite.co.uk/user/htdocs/"> AllowOverride All </Directory> </VirtualHost> and ... <VirtualHost <virtual interface IP>:80> ServerAdmin webmaster@localhost ServerName temp.co.uk DocumentRoot "/home/webmaster/development/temp" ErrorLog "/home

Categories : Ubuntu

Which methods can be used to detect memory overwritten in Linux kernel?
Take a look at Kmemcheck tool. You may enable it in your kernel configuration and rebuild the kernel. Kmemcheck may slow the system down significantly but it can detect incorrect memory accesses that would be very hard to find otherwise. For the kernel 4.1 or newer on x86_64 architecture, Kernel Address sanitizer (KASan) may also be an option. It should be much faster than Kmemcheck.

Categories : Linux



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.