[committed, PATCH] Use mmap and cache the view buffer for get_view

H.J. Lu hjl.tools@gmail.com
Wed Feb 11 03:03:00 GMT 2015


On Tue, Feb 10, 2015 at 5:05 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Feb 10, 2015 at 5:52 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Tue, Feb 10, 2015 at 5:35 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Fri, Feb 6, 2015 at 9:04 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>>>> This patch uses mmap if it is available and works.  It also caches the
>>>> view buffer for get_view.  I am checking it in.
>>>>
>>>>
>>>> H.J.
>>>> ---
>>>>         * configure.ac: Add AC_FUNC_MMAP.
>>>>         * config.in: Regenerated.
>>>>         * configure: Likewise.
>>>>         * plugin.c: Include <sys/mman.h>.
>>>>         (MAP_FAILED): New.  Defined if not defined.
>>>>         (PROT_READ): Likewise.
>>>>         (MAP_PRIVATE): Likewise.
>>>>         (view_buffer_t): New.
>>>>         (plugin_input_file_t): Add view_buffer.
>>>>         (get_view): Try mmap and cache the view buffer.
>>>>         (plugin_maybe_claim): Initialize view_buffer.
>>>
>>> Offset passed to mmap must be a multiple of the page size.  This patch
>>> aligns offset passed to mmap.  I checked it in.
>>>
>>> * plugin.c (get_view): Align offset passed to mmap.
>>> ---
>>>  ld/ChangeLog |  4 ++++
>>>  ld/plugin.c  | 15 ++++++++++++---
>>>  2 files changed, 16 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/ld/ChangeLog b/ld/ChangeLog
>>> index bf59ab3..facbbc1 100644
>>> --- a/ld/ChangeLog
>>> +++ b/ld/ChangeLog
>>> @@ -1,3 +1,7 @@
>>> +2015-02-10  H.J. Lu  <hongjiu.lu@intel.com>
>>> +
>>> + * plugin.c (get_view): Align offset passed to mmap.
>>> +
>>>  2015-02-08  H.J. Lu  <hongjiu.lu@intel.com>
>>>
>>
>> I checked in this to add the missing HAVE_GETPAGESIZE check in get_view.
>>
>> --
>> H.J.
>> --
>> commit b677c4562dea82ffaf413e7e9311ca4b9c1c6ec6
>> Author: H.J. Lu <hjl.tools@gmail.com>
>> Date:   Tue Feb 10 05:46:38 2015 -0800
>>
>>     Add the missing HAVE_GETPAGESIZE check in get_view
>>
>
> If plugin didn't claim the file, unmap the buffer.  Committed.

I checked in this patch to initialize use_mmap.

H.J.
---
diff --git a/ld/ChangeLog b/ld/ChangeLog
index b17fa40..df71ec2 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,9 @@
 2015-02-10  H.J. Lu  <hongjiu.lu@intel.com>

+ * plugin.c (plugin_maybe_claim): Initialize use_mmap.
+
+2015-02-10  H.J. Lu  <hongjiu.lu@intel.com>
+
  * plugin.c (plugin_input_file_t): Add use_mmap.
  (plugin_pagesize): New.
  (get_view): Use plugin_pagesize.  Set use_mmap if mmap is used.
diff --git a/ld/plugin.c b/ld/plugin.c
index 89083db..e5bdb01 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -1080,6 +1080,7 @@ plugin_maybe_claim (lang_input_statement_type *entry)
   input->view_buffer.filesize = 0;
   input->view_buffer.offset = 0;
   input->fd = fd;
+  input->use_mmap = FALSE;
   input->offset = offset;
   input->filesize = filesize;
   input->name = plugin_strdup (abfd, ibfd->filename);



More information about the Binutils mailing list