public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* memmove syscall
@ 2004-02-04 12:32 Nikolay Igotti
  2004-02-06  3:52 ` Rik van Riel
  0 siblings, 1 reply; 4+ messages in thread
From: Nikolay Igotti @ 2004-02-04 12:32 UTC (permalink / raw)
  To: linux-kernel

   Maybe this is kinda crazy (or known) idea, but why don't we create 
syscall
allowing large copies by just manipulating MMU page table, i.e.

asmlinkage long sys_memmove(void* dst, void* src, int size) {
  if ((dst & ~PAGE_SIZE) ||(src & ~PAGE_SIZE) || (size & ~PAGE_SIZE))
                return -EINVAL;

   return mmu_remap_pages(src,  dst, size / PAGE_SIZE);
}


 This could be useful for copying of large amounts of data when we know that
source not gonna be used anymore (typical example is garbage collector).
 
 Please reply directly, as I'm not on the list.


  Nikolay.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: memmove syscall
  2004-02-04 12:32 memmove syscall Nikolay Igotti
@ 2004-02-06  3:52 ` Rik van Riel
  2004-02-06  4:45   ` Nikolay Igotti
  0 siblings, 1 reply; 4+ messages in thread
From: Rik van Riel @ 2004-02-06  3:52 UTC (permalink / raw)
  To: Nikolay Igotti; +Cc: linux-kernel

On Wed, 4 Feb 2004, Nikolay Igotti wrote:

>    Maybe this is kinda crazy (or known) idea, but why don't we create
> syscall allowing large copies by just manipulating MMU page table, i.e.

>    return mmu_remap_pages(src,  dst, size / PAGE_SIZE);

Did you look at mremap(2) ?

Linux has had mremap for a very very long time...

-- 
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: memmove syscall
  2004-02-06  3:52 ` Rik van Riel
@ 2004-02-06  4:45   ` Nikolay Igotti
  2004-02-07  1:23     ` Jamie Lokier
  0 siblings, 1 reply; 4+ messages in thread
From: Nikolay Igotti @ 2004-02-06  4:45 UTC (permalink / raw)
  To: Rik van Riel; +Cc: linux-kernel

Rik van Riel wrote:

>On Wed, 4 Feb 2004, Nikolay Igotti wrote:
>
>  
>
>>   Maybe this is kinda crazy (or known) idea, but why don't we create
>>syscall allowing large copies by just manipulating MMU page table, i.e.
>>    
>>
>
>  
>
>>   return mmu_remap_pages(src,  dst, size / PAGE_SIZE);
>>    
>>
>
>Did you look at mremap(2) ?
>  
>
 If I get it correctly:

       mremap expands (or shrinks) an  existing  memory  mapping,  
potentially
       moving  it  at  the same time (controlled by the flags argument 
and the
       available virtual address space).


And this syscall can be only used for realloc() kind of stuff, as you're 
not allowed to change
virtual address of some page to desired value, but whole point is to 
allow very fast page-aligned
memory moving (or to be exact - swapping, as I guess dst pages should be 
mapped where src ones was
mapped before, to keep things sane).

 Obvious applications for this syscall - Large Object Spaces in 
different memory management systems
-  if space is allocated in pages, defragmentation becomes very cheap.

 Also there could be other applications, like execution-time program 
obfuscators, just shuffling
program stack and data in fancy way :), or tools for improvment of 
interactive behavior of
KDE/Gnome by putting images (or other location-neutral(pointerless) 
data) into nearby virtual
memory locations (so they'll be swapped in and out together, as they 
should).

  If it can be achieved with existing syscalls, I'd be happy to know how 
to do that :).

    Thanks,
      Nikolay






 





 






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: memmove syscall
  2004-02-06  4:45   ` Nikolay Igotti
@ 2004-02-07  1:23     ` Jamie Lokier
  0 siblings, 0 replies; 4+ messages in thread
From: Jamie Lokier @ 2004-02-07  1:23 UTC (permalink / raw)
  To: Nikolay Igotti; +Cc: Rik van Riel, linux-kernel

Nikolay Igotti wrote:
>       mremap expands (or shrinks) an  existing  memory  mapping,  
> potentially
>       moving  it  at  the same time (controlled by the flags argument 
> and the
>       available virtual address space).
> 
> 
> And this syscall can be only used for realloc() kind of stuff, as you're 
> not allowed to change
> virtual address of some page to desired value,

Have you looked at the MREMAP_FIXED flag?

-- Jamie

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-02-07  1:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-04 12:32 memmove syscall Nikolay Igotti
2004-02-06  3:52 ` Rik van Riel
2004-02-06  4:45   ` Nikolay Igotti
2004-02-07  1:23     ` Jamie Lokier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox