From: Ilya Smith <blackzert@gmail.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
x86@kernel.org, kirill.shutemov@linux.intel.com,
dsafonov@virtuozzo.com, hughd@google.com,
gregkh@linuxfoundation.org, craigb@google.com, oleg@redhat.com,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] Take mmap_min_addr into account while choosing unmapped address for x86-64.
Date: Tue, 27 Feb 2018 16:27:29 +0300 [thread overview]
Message-ID: <B6A5E9B0-4986-4CD4-B01A-B6218D859579@gmail.com> (raw)
In-Reply-To: <20180227085726.GC15357@dhcp22.suse.cz>
>
> mmap_min_addr handling is a bit mess... As you say, we would return
> EPERM rather than ENOMEM which can be confusing but depleting the
> address space like that is quite unlikely on 64b unless I am missing.
> It is good to be in sync here with the generic implementation though,
> IMO.
>
If we take a look on mm/mmap.c:
#ifndef HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
unsigned long
arch_get_unmapped_area_topdown(
…
if (len > TASK_SIZE - mmap_min_addr)
return -ENOMEM;
…
info.low_limit = max(PAGE_SIZE, mmap_min_addr);
And this one looks like a generic implementation.
But for many other architectures like arch/parisc/kernel/sys_parisc.c
or arch/x86/kernel/sys_x86_64.c
info.low_limit = PAGE_SIZE;
What is looks like an issue for me.
Here is C code could be used as test-case:
#include <errno.h>
#include <stdio.h>
#include <sys/mman.h>
int main() {
char buffer[1024];
unsigned long len = 1ULL << 46;
while(len) {
void *ptr = mmap(4096, len, 0, MAP_PRIVATE | MAP_ANONYMOUS , -1, 0);
if (ptr == MAP_FAILED) {
if (errno == EPERM)
break;
if (errno == ENOMEM) {
len >>= 1;
continue;
}
return -1;
}
}
if (errno == EPERM) {
printf("Test failed, you have wrong ret code EPERM\n");
sprintf(buffer, "cat /proc/%d/maps", getpid());
system(buffer);
return -1;
}
return 0;
}
>>
>> + if (addr < mmap_min_addr)
>> + return false;
>> +
>> return (addr > DEFAULT_MAP_WINDOW) == (addr + len > DEFAULT_MAP_WINDOW);
>
> But is this one necessary? We do sanitze hint address before going to
> get_unmapped_address AFAIR.
>
I’m agree, looks like I was trying to fix something that already fine.
Thanks,
Ilya
next prev parent reply other threads:[~2018-02-27 13:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-26 21:12 Ilya Smith
2018-02-27 8:57 ` Michal Hocko
2018-02-27 13:27 ` Ilya Smith [this message]
2018-02-28 7:17 ` Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B6A5E9B0-4986-4CD4-B01A-B6218D859579@gmail.com \
--to=blackzert@gmail.com \
--cc=craigb@google.com \
--cc=dsafonov@virtuozzo.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=hughd@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@kernel.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®