aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2012-05-21 15:39:42 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2012-05-21 15:39:42 -0400
commit0ad8c6a22d03a1598f7cc6585c65354dadca62ad (patch)
tree1507deef3d55d5f3c71b2f76924fe1f6c6211905 /fs/proc
parent8527f8e2934683e53405fbe876a4e6f4a0c46eb8 (diff)
parent76e10d158efb6d4516018846f60c2ab5501900bc (diff)
Merge tag 'v3.4' with SCSI updates, needed for subsequent firewire-sbp2 changes
Linux 3.4
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/base.c63
-rw-r--r--fs/proc/stat.c34
-rw-r--r--fs/proc/task_mmu.c15
3 files changed, 60 insertions, 52 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 1c8b280146d7..57b8159f26f3 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1799,10 +1799,15 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)
1799 if (task) { 1799 if (task) {
1800 files = get_files_struct(task); 1800 files = get_files_struct(task);
1801 if (files) { 1801 if (files) {
1802 struct file *file;
1802 rcu_read_lock(); 1803 rcu_read_lock();
1803 if (fcheck_files(files, fd)) { 1804 file = fcheck_files(files, fd);
1805 if (file) {
1806 unsigned i_mode, f_mode = file->f_mode;
1807
1804 rcu_read_unlock(); 1808 rcu_read_unlock();
1805 put_files_struct(files); 1809 put_files_struct(files);
1810
1806 if (task_dumpable(task)) { 1811 if (task_dumpable(task)) {
1807 rcu_read_lock(); 1812 rcu_read_lock();
1808 cred = __task_cred(task); 1813 cred = __task_cred(task);
@@ -1813,7 +1818,14 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)
1813 inode->i_uid = 0; 1818 inode->i_uid = 0;
1814 inode->i_gid = 0; 1819 inode->i_gid = 0;
1815 } 1820 }
1816 inode->i_mode &= ~(S_ISUID | S_ISGID); 1821
1822 i_mode = S_IFLNK;
1823 if (f_mode & FMODE_READ)
1824 i_mode |= S_IRUSR | S_IXUSR;
1825 if (f_mode & FMODE_WRITE)
1826 i_mode |= S_IWUSR | S_IXUSR;
1827 inode->i_mode = i_mode;
1828
1817 security_task_to_inode(task, inode); 1829 security_task_to_inode(task, inode);
1818 put_task_struct(task); 1830 put_task_struct(task);
1819 return 1; 1831 return 1;
@@ -1837,8 +1849,6 @@ static struct dentry *proc_fd_instantiate(struct inode *dir,
1837 struct dentry *dentry, struct task_struct *task, const void *ptr) 1849 struct dentry *dentry, struct task_struct *task, const void *ptr)
1838{ 1850{
1839 unsigned fd = *(const unsigned *)ptr; 1851 unsigned fd = *(const unsigned *)ptr;
1840 struct file *file;
1841 struct files_struct *files;
1842 struct inode *inode; 1852 struct inode *inode;
1843 struct proc_inode *ei; 1853 struct proc_inode *ei;
1844 struct dentry *error = ERR_PTR(-ENOENT); 1854 struct dentry *error = ERR_PTR(-ENOENT);
@@ -1848,25 +1858,6 @@ static struct dentry *proc_fd_instantiate(struct inode *dir,
1848 goto out; 1858 goto out;
1849 ei = PROC_I(inode); 1859 ei = PROC_I(inode);
1850 ei->fd = fd; 1860 ei->fd = fd;
1851 files = get_files_struct(task);
1852 if (!files)
1853 goto out_iput;
1854 inode->i_mode = S_IFLNK;
1855
1856 /*
1857 * We are not taking a ref to the file structure, so we must
1858 * hold ->file_lock.
1859 */
1860 spin_lock(&files->file_lock);
1861 file = fcheck_files(files, fd);
1862 if (!file)
1863 goto out_unlock;
1864 if (file->f_mode & FMODE_READ)
1865 inode->i_mode |= S_IRUSR | S_IXUSR;
1866 if (file->f_mode & FMODE_WRITE)
1867 inode->i_mode |= S_IWUSR | S_IXUSR;
1868 spin_unlock(&files->file_lock);
1869 put_files_struct(files);
1870 1861
1871 inode->i_op = &proc_pid_link_inode_operations; 1862 inode->i_op = &proc_pid_link_inode_operations;
1872 inode->i_size = 64; 1863 inode->i_size = 64;
@@ -1879,12 +1870,6 @@ static struct dentry *proc_fd_instantiate(struct inode *dir,
1879 1870
1880 out: 1871 out:
1881 return error; 1872 return error;
1882out_unlock:
1883 spin_unlock(&files->file_lock);
1884 put_files_struct(files);
1885out_iput:
1886 iput(inode);
1887 goto out;
1888} 1873}
1889 1874
1890static struct dentry *proc_lookupfd_common(struct inode *dir, 1875static struct dentry *proc_lookupfd_common(struct inode *dir,
@@ -2177,16 +2162,16 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
2177 goto out; 2162 goto out;
2178 2163
2179 result = ERR_PTR(-EACCES); 2164 result = ERR_PTR(-EACCES);
2180 if (lock_trace(task)) 2165 if (!ptrace_may_access(task, PTRACE_MODE_READ))
2181 goto out_put_task; 2166 goto out_put_task;
2182 2167
2183 result = ERR_PTR(-ENOENT); 2168 result = ERR_PTR(-ENOENT);
2184 if (dname_to_vma_addr(dentry, &vm_start, &vm_end)) 2169 if (dname_to_vma_addr(dentry, &vm_start, &vm_end))
2185 goto out_unlock; 2170 goto out_put_task;
2186 2171
2187 mm = get_task_mm(task); 2172 mm = get_task_mm(task);
2188 if (!mm) 2173 if (!mm)
2189 goto out_unlock; 2174 goto out_put_task;
2190 2175
2191 down_read(&mm->mmap_sem); 2176 down_read(&mm->mmap_sem);
2192 vma = find_exact_vma(mm, vm_start, vm_end); 2177 vma = find_exact_vma(mm, vm_start, vm_end);
@@ -2198,8 +2183,6 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
2198out_no_vma: 2183out_no_vma:
2199 up_read(&mm->mmap_sem); 2184 up_read(&mm->mmap_sem);
2200 mmput(mm); 2185 mmput(mm);
2201out_unlock:
2202 unlock_trace(task);
2203out_put_task: 2186out_put_task:
2204 put_task_struct(task); 2187 put_task_struct(task);
2205out: 2188out:
@@ -2233,7 +2216,7 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir)
2233 goto out; 2216 goto out;
2234 2217
2235 ret = -EACCES; 2218 ret = -EACCES;
2236 if (lock_trace(task)) 2219 if (!ptrace_may_access(task, PTRACE_MODE_READ))
2237 goto out_put_task; 2220 goto out_put_task;
2238 2221
2239 ret = 0; 2222 ret = 0;
@@ -2241,12 +2224,12 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir)
2241 case 0: 2224 case 0:
2242 ino = inode->i_ino; 2225 ino = inode->i_ino;
2243 if (filldir(dirent, ".", 1, 0, ino, DT_DIR) < 0) 2226 if (filldir(dirent, ".", 1, 0, ino, DT_DIR) < 0)
2244 goto out_unlock; 2227 goto out_put_task;
2245 filp->f_pos++; 2228 filp->f_pos++;
2246 case 1: 2229 case 1:
2247 ino = parent_ino(dentry); 2230 ino = parent_ino(dentry);
2248 if (filldir(dirent, "..", 2, 1, ino, DT_DIR) < 0) 2231 if (filldir(dirent, "..", 2, 1, ino, DT_DIR) < 0)
2249 goto out_unlock; 2232 goto out_put_task;
2250 filp->f_pos++; 2233 filp->f_pos++;
2251 default: 2234 default:
2252 { 2235 {
@@ -2257,7 +2240,7 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir)
2257 2240
2258 mm = get_task_mm(task); 2241 mm = get_task_mm(task);
2259 if (!mm) 2242 if (!mm)
2260 goto out_unlock; 2243 goto out_put_task;
2261 down_read(&mm->mmap_sem); 2244 down_read(&mm->mmap_sem);
2262 2245
2263 nr_files = 0; 2246 nr_files = 0;
@@ -2287,7 +2270,7 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir)
2287 flex_array_free(fa); 2270 flex_array_free(fa);
2288 up_read(&mm->mmap_sem); 2271 up_read(&mm->mmap_sem);
2289 mmput(mm); 2272 mmput(mm);
2290 goto out_unlock; 2273 goto out_put_task;
2291 } 2274 }
2292 for (i = 0, vma = mm->mmap, pos = 2; vma; 2275 for (i = 0, vma = mm->mmap, pos = 2; vma;
2293 vma = vma->vm_next) { 2276 vma = vma->vm_next) {
@@ -2332,8 +2315,6 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir)
2332 } 2315 }
2333 } 2316 }
2334 2317
2335out_unlock:
2336 unlock_trace(task);
2337out_put_task: 2318out_put_task:
2338 put_task_struct(task); 2319 put_task_struct(task);
2339out: 2320out:
diff --git a/fs/proc/stat.c b/fs/proc/stat.c
index 6a0c62d6e442..64c3b3172367 100644
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -18,19 +18,39 @@
18#ifndef arch_irq_stat 18#ifndef arch_irq_stat
19#define arch_irq_stat() 0 19#define arch_irq_stat() 0
20#endif 20#endif
21#ifndef arch_idle_time 21
22#define arch_idle_time(cpu) 0 22#ifdef arch_idle_time
23#endif 23
24static cputime64_t get_idle_time(int cpu)
25{
26 cputime64_t idle;
27
28 idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE];
29 if (cpu_online(cpu) && !nr_iowait_cpu(cpu))
30 idle += arch_idle_time(cpu);
31 return idle;
32}
33
34static cputime64_t get_iowait_time(int cpu)
35{
36 cputime64_t iowait;
37
38 iowait = kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT];
39 if (cpu_online(cpu) && nr_iowait_cpu(cpu))
40 iowait += arch_idle_time(cpu);
41 return iowait;
42}
43
44#else
24 45
25static u64 get_idle_time(int cpu) 46static u64 get_idle_time(int cpu)
26{ 47{
27 u64 idle, idle_time = get_cpu_idle_time_us(cpu, NULL); 48 u64 idle, idle_time = get_cpu_idle_time_us(cpu, NULL);
28 49
29 if (idle_time == -1ULL) { 50 if (idle_time == -1ULL)
30 /* !NO_HZ so we can rely on cpustat.idle */ 51 /* !NO_HZ so we can rely on cpustat.idle */
31 idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE]; 52 idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE];
32 idle += arch_idle_time(cpu); 53 else
33 } else
34 idle = usecs_to_cputime64(idle_time); 54 idle = usecs_to_cputime64(idle_time);
35 55
36 return idle; 56 return idle;
@@ -49,6 +69,8 @@ static u64 get_iowait_time(int cpu)
49 return iowait; 69 return iowait;
50} 70}
51 71
72#endif
73
52static int show_stat(struct seq_file *p, void *v) 74static int show_stat(struct seq_file *p, void *v)
53{ 75{
54 int i, j; 76 int i, j;
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 2b9a7607cbd5..1030a716d155 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -597,9 +597,6 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,
597 if (!page) 597 if (!page)
598 continue; 598 continue;
599 599
600 if (PageReserved(page))
601 continue;
602
603 /* Clear accessed and referenced bits. */ 600 /* Clear accessed and referenced bits. */
604 ptep_test_and_clear_young(vma, addr, pte); 601 ptep_test_and_clear_young(vma, addr, pte);
605 ClearPageReferenced(page); 602 ClearPageReferenced(page);
@@ -750,6 +747,8 @@ static void pte_to_pagemap_entry(pagemap_entry_t *pme, pte_t pte)
750 else if (pte_present(pte)) 747 else if (pte_present(pte))
751 *pme = make_pme(PM_PFRAME(pte_pfn(pte)) 748 *pme = make_pme(PM_PFRAME(pte_pfn(pte))
752 | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT); 749 | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT);
750 else
751 *pme = make_pme(PM_NOT_PRESENT);
753} 752}
754 753
755#ifdef CONFIG_TRANSPARENT_HUGEPAGE 754#ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -764,6 +763,8 @@ static void thp_pmd_to_pagemap_entry(pagemap_entry_t *pme,
764 if (pmd_present(pmd)) 763 if (pmd_present(pmd))
765 *pme = make_pme(PM_PFRAME(pmd_pfn(pmd) + offset) 764 *pme = make_pme(PM_PFRAME(pmd_pfn(pmd) + offset)
766 | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT); 765 | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT);
766 else
767 *pme = make_pme(PM_NOT_PRESENT);
767} 768}
768#else 769#else
769static inline void thp_pmd_to_pagemap_entry(pagemap_entry_t *pme, 770static inline void thp_pmd_to_pagemap_entry(pagemap_entry_t *pme,
@@ -804,8 +805,10 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
804 805
805 /* check to see if we've left 'vma' behind 806 /* check to see if we've left 'vma' behind
806 * and need a new, higher one */ 807 * and need a new, higher one */
807 if (vma && (addr >= vma->vm_end)) 808 if (vma && (addr >= vma->vm_end)) {
808 vma = find_vma(walk->mm, addr); 809 vma = find_vma(walk->mm, addr);
810 pme = make_pme(PM_NOT_PRESENT);
811 }
809 812
810 /* check that 'vma' actually covers this address, 813 /* check that 'vma' actually covers this address,
811 * and that it isn't a huge page vma */ 814 * and that it isn't a huge page vma */
@@ -833,6 +836,8 @@ static void huge_pte_to_pagemap_entry(pagemap_entry_t *pme,
833 if (pte_present(pte)) 836 if (pte_present(pte))
834 *pme = make_pme(PM_PFRAME(pte_pfn(pte) + offset) 837 *pme = make_pme(PM_PFRAME(pte_pfn(pte) + offset)
835 | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT); 838 | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT);
839 else
840 *pme = make_pme(PM_NOT_PRESENT);
836} 841}
837 842
838/* This function walks within one hugetlb entry in the single call */ 843/* This function walks within one hugetlb entry in the single call */
@@ -842,7 +847,7 @@ static int pagemap_hugetlb_range(pte_t *pte, unsigned long hmask,
842{ 847{
843 struct pagemapread *pm = walk->private; 848 struct pagemapread *pm = walk->private;
844 int err = 0; 849 int err = 0;
845 pagemap_entry_t pme = make_pme(PM_NOT_PRESENT); 850 pagemap_entry_t pme;
846 851
847 for (; addr != end; addr += PAGE_SIZE) { 852 for (; addr != end; addr += PAGE_SIZE) {
848 int offset = (addr & ~hmask) >> PAGE_SHIFT; 853 int offset = (addr & ~hmask) >> PAGE_SHIFT;