Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: chromeos/hugepage_text/hugepage_text.cc

Issue 1619713007: Make text section 2MB aligned for hugepages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // Author: Ken Chen <kenchen@google.com> 4 // Author: Ken Chen <kenchen@google.com>
5 // 5 //
6 // hugepage text library to remap process executable segment with hugepages. 6 // hugepage text library to remap process executable segment with hugepages.
7 7
8 #include "chromeos/hugepage_text/hugepage_text.h" 8 #include "chromeos/hugepage_text/hugepage_text.h"
9 9
10 #include <link.h> 10 #include <link.h>
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 166
167 // Top level text remapping function. 167 // Top level text remapping function.
168 // 168 //
169 // Inputs: vaddr, the starting virtual address to remap to hugepage 169 // Inputs: vaddr, the starting virtual address to remap to hugepage
170 // hsize, size of the memory segment to remap in bytes 170 // hsize, size of the memory segment to remap in bytes
171 // Return: none 171 // Return: none
172 // Effect: physical backing page changed from small page to hugepage. If there 172 // Effect: physical backing page changed from small page to hugepage. If there
173 // are error condition, the remaping operation is aborted. 173 // are error condition, the remaping operation is aborted.
174 static void RemapHugetlbText(void* vaddr, const size_t segsize) { 174 static void RemapHugetlbText(void* vaddr, const size_t segsize) {
175 int hsize = segsize; 175 // remove unaligned head regions
176 size_t head_gap = (kHpageSize - (size_t)vaddr % kHpageSize) % kHpageSize;
Daniel Erat 2016/02/01 16:46:15 use c++-style casts (e.g. static_cast<size_t>()) h
yunlian 2016/02/01 17:31:56 Done.
177 size_t addr = (size_t)vaddr + head_gap;
178
179 int hsize = segsize - head_gap;
176 if (segsize > kHpageSize * kNumHugePages) 180 if (segsize > kHpageSize * kNumHugePages)
177 hsize = kHpageSize * kNumHugePages; 181 hsize = kHpageSize * kNumHugePages;
178 hsize = hsize & kHpageMask; 182 hsize = hsize & kHpageMask;
179 183
180 if (hsize == 0) 184 if (hsize == 0)
181 return; 185 return;
182 186
183 MremapHugetlbText(vaddr, hsize); 187 MremapHugetlbText((void *)addr, hsize);
184 } 188 }
185 189
186 // For a given ELF program header descriptor, iterates over all segments within 190 // For a given ELF program header descriptor, iterates over all segments within
187 // it and find the first segment that has PT_LOAD and is executable, call 191 // it and find the first segment that has PT_LOAD and is executable, call
188 // RemapHugetlbText(). 192 // RemapHugetlbText().
189 // 193 //
190 // Inputs: info: pointer to a struct dl_phdr_info that describes the DSO. 194 // Inputs: info: pointer to a struct dl_phdr_info that describes the DSO.
191 // size: size of the above structure (not used in this function). 195 // size: size of the above structure (not used in this function).
192 // data: user param (not used in this function). 196 // data: user param (not used in this function).
193 // Return: always return true. The value is propagated by dl_iterate_phdr(). 197 // Return: always return true. The value is propagated by dl_iterate_phdr().
(...skipping 18 matching lines...) Expand all
212 216
213 // Main library function. This function will iterate all ELF segments and 217 // Main library function. This function will iterate all ELF segments and
214 // attempt to remap text segment from small page to hugepage. 218 // attempt to remap text segment from small page to hugepage.
215 // If remapping is successful. All error conditions are soft fail such that 219 // If remapping is successful. All error conditions are soft fail such that
216 // effect will be rolled back and remap operation will be aborted. 220 // effect will be rolled back and remap operation will be aborted.
217 void ReloadElfTextInHugePages(void) { 221 void ReloadElfTextInHugePages(void) {
218 dl_iterate_phdr(FilterElfHeader, 0); 222 dl_iterate_phdr(FilterElfHeader, 0);
219 } 223 }
220 224
221 } // namespace chromeos 225 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698