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

Side by Side Diff: sandbox/linux/seccomp/madvise.cc

Issue 997009: Compute and pring the time that it takes to execute system calls. This data... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « sandbox/linux/seccomp/ipc.cc ('k') | sandbox/linux/seccomp/mmap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 4
5 #include "debug.h" 5 #include "debug.h"
6 #include "sandbox_impl.h" 6 #include "sandbox_impl.h"
7 7
8 namespace playground { 8 namespace playground {
9 9
10 int Sandbox::sandbox_madvise(void* start, size_t length, int advice) { 10 int Sandbox::sandbox_madvise(void* start, size_t length, int advice) {
11 Debug::syscall(__NR_madvise, "Executing handler"); 11 long long tm;
12 Debug::syscall(&tm, __NR_madvise, "Executing handler");
12 struct { 13 struct {
13 int sysnum; 14 int sysnum;
14 long long cookie; 15 long long cookie;
15 MAdvise madvise_req; 16 MAdvise madvise_req;
16 } __attribute__((packed)) request; 17 } __attribute__((packed)) request;
17 request.sysnum = __NR_madvise; 18 request.sysnum = __NR_madvise;
18 request.cookie = cookie(); 19 request.cookie = cookie();
19 request.madvise_req.start = start; 20 request.madvise_req.start = start;
20 request.madvise_req.len = length; 21 request.madvise_req.len = length;
21 request.madvise_req.advice = advice; 22 request.madvise_req.advice = advice;
22 23
23 long rc; 24 long rc;
24 SysCalls sys; 25 SysCalls sys;
25 if (write(sys, processFdPub(), &request, sizeof(request)) != 26 if (write(sys, processFdPub(), &request, sizeof(request)) !=
26 sizeof(request) || 27 sizeof(request) ||
27 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { 28 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) {
28 die("Failed to forward madvise() request [sandbox]"); 29 die("Failed to forward madvise() request [sandbox]");
29 } 30 }
31 Debug::elapsed(tm, __NR_madvise);
30 return static_cast<int>(rc); 32 return static_cast<int>(rc);
31 } 33 }
32 34
33 bool Sandbox::process_madvise(int parentMapsFd, int sandboxFd, int threadFdPub, 35 bool Sandbox::process_madvise(int parentMapsFd, int sandboxFd, int threadFdPub,
34 int threadFd, SecureMem::Args* mem) { 36 int threadFd, SecureMem::Args* mem) {
35 // Read request 37 // Read request
36 MAdvise madvise_req; 38 MAdvise madvise_req;
37 SysCalls sys; 39 SysCalls sys;
38 if (read(sys, sandboxFd, &madvise_req, sizeof(madvise_req)) != 40 if (read(sys, sandboxFd, &madvise_req, sizeof(madvise_req)) !=
39 sizeof(madvise_req)) { 41 sizeof(madvise_req)) {
(...skipping 30 matching lines...) Expand all
70 } 72 }
71 } 73 }
72 74
73 // Changing attributes on memory regions that were newly mapped inside of 75 // Changing attributes on memory regions that were newly mapped inside of
74 // the sandbox is OK. 76 // the sandbox is OK.
75 goto ok; 77 goto ok;
76 } 78 }
77 } 79 }
78 80
79 } // namespace 81 } // namespace
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp/ipc.cc ('k') | sandbox/linux/seccomp/mmap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698