-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinux_kernel.patch
1259 lines (1163 loc) · 40.4 KB
/
linux_kernel.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/.gitignore b/.gitignore
index 97ba6b79834c..26a59b978e6b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -132,3 +132,6 @@ all.config
# Kdevelop4
*.kdev4
+
+#source
+source
diff --git a/fs/read_write.c b/fs/read_write.c
index 85fd7a8ee29e..a158abeca3cf 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -557,6 +557,7 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
return ret;
}
+EXPORT_SYMBOL(vfs_write);
static inline loff_t file_pos_read(struct file *file)
{
diff --git a/include/trace/events/filemap.h b/include/trace/events/filemap.h
index ee05db7ee8d2..3c7762aaa3b4 100644
--- a/include/trace/events/filemap.h
+++ b/include/trace/events/filemap.h
@@ -44,6 +44,38 @@ DECLARE_EVENT_CLASS(mm_filemap_op_page_cache,
__entry->index << PAGE_SHIFT)
);
+DECLARE_EVENT_CLASS(mm_filemap_op_fsl,
+
+ TP_PROTO(struct page *page, struct file* file, int origin, unsigned long address),
+
+ TP_ARGS(page, file, origin, address),
+
+ TP_STRUCT__entry(
+ __field(unsigned long, pfn)
+ __field(unsigned long, i_ino)
+ __field(unsigned long, index)
+ __field(dev_t, s_dev)
+ ),
+
+ TP_fast_assign(
+ __entry->pfn = page_to_pfn(page);
+ __entry->i_ino = page->mapping->host->i_ino;
+ __entry->index = page->index;
+ if (page->mapping->host->i_sb)
+ __entry->s_dev = page->mapping->host->i_sb->s_dev;
+ else
+ __entry->s_dev = page->mapping->host->i_rdev;
+ ),
+
+ TP_printk("dev %d:%d ino %lx page=%p pfn=%lu ofs=%lu",
+ MAJOR(__entry->s_dev), MINOR(__entry->s_dev),
+ __entry->i_ino,
+ pfn_to_page(__entry->pfn),
+ __entry->pfn,
+ __entry->index << PAGE_SHIFT)
+);
+
+
DEFINE_EVENT(mm_filemap_op_page_cache, mm_filemap_delete_from_page_cache,
TP_PROTO(struct page *page),
TP_ARGS(page)
@@ -54,6 +86,11 @@ DEFINE_EVENT(mm_filemap_op_page_cache, mm_filemap_add_to_page_cache,
TP_ARGS(page)
);
+DEFINE_EVENT(mm_filemap_op_fsl, mm_filemap_fsl_read,
+ TP_PROTO(struct page *page, struct file* file, int origin, unsigned long address),
+ TP_ARGS(page, file, origin, address)
+ );
+
TRACE_EVENT(filemap_set_wb_err,
TP_PROTO(struct address_space *mapping, errseq_t eseq),
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index 32db72c7c055..31a176990a1e 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -79,6 +79,31 @@ TRACE_EVENT(writeback_dirty_page,
)
);
+TRACE_EVENT(fsl_writeback_dirty_page,
+
+ TP_PROTO(struct page *page, int fd, struct inode *inode),
+
+ TP_ARGS(page, fd, inode),
+
+ TP_STRUCT__entry (
+ __field(int, fd)
+ __field(pgoff_t, index)
+ __field(loff_t, size)
+ ),
+
+ TP_fast_assign(
+ __entry->fd = fd;
+ __entry->index = page->index;
+ __entry->size = inode->i_size;
+ ),
+
+ TP_printk("fd=%d index=%lu size=%lld",
+ __entry->fd,
+ __entry->index,
+ __entry->size
+ )
+);
+
DECLARE_EVENT_CLASS(writeback_dirty_inode_template,
TP_PROTO(struct inode *inode, int flags),
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 02a0b01380d8..a55787cc99de 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -309,6 +309,7 @@ const char *kallsyms_lookup(unsigned long addr,
offset, modname, namebuf);
return ret;
}
+EXPORT_SYMBOL(kallsyms_lookup);
int lookup_symbol_name(unsigned long addr, char *symname)
{
diff --git a/mm/filemap.c b/mm/filemap.c
index 52517f28e6f4..fc4673effa9d 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -118,8 +118,8 @@ static int page_cache_tree_insert(struct address_space *mapping,
void **slot;
int error;
- error = __radix_tree_create(&mapping->i_pages, page->index, 0,
- &node, &slot);
+ error = __radix_tree_create(&mapping->i_pages, page->index, 0, &node,
+ &slot);
if (error)
return error;
if (*slot) {
@@ -156,14 +156,14 @@ static void page_cache_tree_delete(struct address_space *mapping,
struct radix_tree_node *node;
void **slot;
- __radix_tree_lookup(&mapping->i_pages, page->index + i,
- &node, &slot);
+ __radix_tree_lookup(&mapping->i_pages, page->index + i, &node,
+ &slot);
VM_BUG_ON_PAGE(!node && nr != 1, page);
radix_tree_clear_tags(&mapping->i_pages, node, slot);
__radix_tree_replace(&mapping->i_pages, node, slot, shadow,
- workingset_lookup_update(mapping));
+ workingset_lookup_update(mapping));
}
page->mapping = NULL;
@@ -267,7 +267,7 @@ void __delete_from_page_cache(struct page *page, void *shadow)
}
static void page_cache_free_page(struct address_space *mapping,
- struct page *page)
+ struct page *page)
{
void (*freepage)(struct page *);
@@ -319,9 +319,8 @@ EXPORT_SYMBOL(delete_from_page_cache);
*
* The function expects the i_pages lock to be held.
*/
-static void
-page_cache_tree_delete_batch(struct address_space *mapping,
- struct pagevec *pvec)
+static void page_cache_tree_delete_batch(struct address_space *mapping,
+ struct pagevec *pvec)
{
struct radix_tree_iter iter;
void **slot;
@@ -331,11 +330,11 @@ page_cache_tree_delete_batch(struct address_space *mapping,
pgoff_t start;
start = pvec->pages[0]->index;
- radix_tree_for_each_slot(slot, &mapping->i_pages, &iter, start) {
+ radix_tree_for_each_slot (slot, &mapping->i_pages, &iter, start) {
if (i >= pagevec_count(pvec) && !tail_pages)
break;
- page = radix_tree_deref_slot_protected(slot,
- &mapping->i_pages.xa_lock);
+ page = radix_tree_deref_slot_protected(
+ slot, &mapping->i_pages.xa_lock);
if (radix_tree_exceptional_entry(page))
continue;
if (!tail_pages) {
@@ -360,7 +359,7 @@ page_cache_tree_delete_batch(struct address_space *mapping,
}
radix_tree_clear_tags(&mapping->i_pages, iter.node, slot);
__radix_tree_replace(&mapping->i_pages, iter.node, slot, NULL,
- workingset_lookup_update(mapping));
+ workingset_lookup_update(mapping));
total_pages++;
}
mapping->nrpages -= total_pages;
@@ -428,7 +427,7 @@ static int filemap_check_and_keep_errors(struct address_space *mapping)
* be waited upon, and not just skipped over.
*/
int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
- loff_t end, int sync_mode)
+ loff_t end, int sync_mode)
{
int ret;
struct writeback_control wbc = {
@@ -448,7 +447,7 @@ int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
}
static inline int __filemap_fdatawrite(struct address_space *mapping,
- int sync_mode)
+ int sync_mode)
{
return __filemap_fdatawrite_range(mapping, 0, LLONG_MAX, sync_mode);
}
@@ -460,7 +459,7 @@ int filemap_fdatawrite(struct address_space *mapping)
EXPORT_SYMBOL(filemap_fdatawrite);
int filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
- loff_t end)
+ loff_t end)
{
return __filemap_fdatawrite_range(mapping, start, end, WB_SYNC_ALL);
}
@@ -488,8 +487,8 @@ EXPORT_SYMBOL(filemap_flush);
* Find at least one page in the range supplied, usually used to check if
* direct writing in this range will trigger a writeback.
*/
-bool filemap_range_has_page(struct address_space *mapping,
- loff_t start_byte, loff_t end_byte)
+bool filemap_range_has_page(struct address_space *mapping, loff_t start_byte,
+ loff_t end_byte)
{
pgoff_t index = start_byte >> PAGE_SHIFT;
pgoff_t end = end_byte >> PAGE_SHIFT;
@@ -509,7 +508,7 @@ bool filemap_range_has_page(struct address_space *mapping,
EXPORT_SYMBOL(filemap_range_has_page);
static void __filemap_fdatawait_range(struct address_space *mapping,
- loff_t start_byte, loff_t end_byte)
+ loff_t start_byte, loff_t end_byte)
{
pgoff_t index = start_byte >> PAGE_SHIFT;
pgoff_t end = end_byte >> PAGE_SHIFT;
@@ -523,8 +522,8 @@ static void __filemap_fdatawait_range(struct address_space *mapping,
while (index <= end) {
unsigned i;
- nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index,
- end, PAGECACHE_TAG_WRITEBACK);
+ nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end,
+ PAGECACHE_TAG_WRITEBACK);
if (!nr_pages)
break;
@@ -606,7 +605,7 @@ EXPORT_SYMBOL(filemap_fdatawait_keep_errors);
static bool mapping_needs_writeback(struct address_space *mapping)
{
return (!dax_mapping(mapping) && mapping->nrpages) ||
- (dax_mapping(mapping) && mapping->nrexceptional);
+ (dax_mapping(mapping) && mapping->nrexceptional);
}
int filemap_write_and_wait(struct address_space *mapping)
@@ -647,8 +646,8 @@ EXPORT_SYMBOL(filemap_write_and_wait);
* Note that @lend is inclusive (describes the last byte to be written) so
* that this function can be used to write to the very end-of-file (end = -1).
*/
-int filemap_write_and_wait_range(struct address_space *mapping,
- loff_t lstart, loff_t lend)
+int filemap_write_and_wait_range(struct address_space *mapping, loff_t lstart,
+ loff_t lend)
{
int err = 0;
@@ -657,8 +656,8 @@ int filemap_write_and_wait_range(struct address_space *mapping,
WB_SYNC_ALL);
/* See comment of filemap_write_and_wait() */
if (err != -EIO) {
- int err2 = filemap_fdatawait_range(mapping,
- lstart, lend);
+ int err2 =
+ filemap_fdatawait_range(mapping, lstart, lend);
if (!err)
err = err2;
} else {
@@ -714,7 +713,7 @@ int file_check_and_advance_wb_err(struct file *file)
spin_lock(&file->f_lock);
old = file->f_wb_err;
err = errseq_check_and_advance(&mapping->wb_err,
- &file->f_wb_err);
+ &file->f_wb_err);
trace_file_check_and_advance_wb_err(file, old);
spin_unlock(&file->f_lock);
}
@@ -836,8 +835,8 @@ static int __add_to_page_cache_locked(struct page *page,
VM_BUG_ON_PAGE(PageSwapBacked(page), page);
if (!huge) {
- error = mem_cgroup_try_charge(page, current->mm,
- gfp_mask, &memcg, false);
+ error = mem_cgroup_try_charge(page, current->mm, gfp_mask,
+ &memcg, false);
if (error)
return error;
}
@@ -888,22 +887,22 @@ static int __add_to_page_cache_locked(struct page *page,
* This function does not add the page to the LRU. The caller must do that.
*/
int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
- pgoff_t offset, gfp_t gfp_mask)
+ pgoff_t offset, gfp_t gfp_mask)
{
- return __add_to_page_cache_locked(page, mapping, offset,
- gfp_mask, NULL);
+ return __add_to_page_cache_locked(page, mapping, offset, gfp_mask,
+ NULL);
}
EXPORT_SYMBOL(add_to_page_cache_locked);
int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
- pgoff_t offset, gfp_t gfp_mask)
+ pgoff_t offset, gfp_t gfp_mask)
{
void *shadow = NULL;
int ret;
__SetPageLocked(page);
- ret = __add_to_page_cache_locked(page, mapping, offset,
- gfp_mask, &shadow);
+ ret = __add_to_page_cache_locked(page, mapping, offset, gfp_mask,
+ &shadow);
if (unlikely(ret))
__ClearPageLocked(page);
else {
@@ -915,8 +914,8 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
* data from the working set, only to cache data that will
* get overwritten with something else, is a waste of memory.
*/
- if (!(gfp_mask & __GFP_WRITE) &&
- shadow && workingset_refault(shadow)) {
+ if (!(gfp_mask & __GFP_WRITE) && shadow &&
+ workingset_refault(shadow)) {
SetPageActive(page);
workingset_activation(page);
} else
@@ -960,7 +959,8 @@ EXPORT_SYMBOL(__page_cache_alloc);
*/
#define PAGE_WAIT_TABLE_BITS 8
#define PAGE_WAIT_TABLE_SIZE (1 << PAGE_WAIT_TABLE_BITS)
-static wait_queue_head_t page_wait_table[PAGE_WAIT_TABLE_SIZE] __cacheline_aligned;
+static wait_queue_head_t
+ page_wait_table[PAGE_WAIT_TABLE_SIZE] __cacheline_aligned;
static wait_queue_head_t *page_waitqueue(struct page *page)
{
@@ -990,14 +990,15 @@ struct wait_page_queue {
wait_queue_entry_t wait;
};
-static int wake_page_function(wait_queue_entry_t *wait, unsigned mode, int sync, void *arg)
+static int wake_page_function(wait_queue_entry_t *wait, unsigned mode, int sync,
+ void *arg)
{
struct wait_page_key *key = arg;
- struct wait_page_queue *wait_page
- = container_of(wait, struct wait_page_queue, wait);
+ struct wait_page_queue *wait_page =
+ container_of(wait, struct wait_page_queue, wait);
if (wait_page->page != key->page)
- return 0;
+ return 0;
key->page_match = 1;
if (wait_page->bit_nr != key->bit_nr)
@@ -1072,7 +1073,8 @@ static void wake_up_page(struct page *page, int bit)
}
static inline int wait_on_page_bit_common(wait_queue_head_t *q,
- struct page *page, int bit_nr, int state, bool lock)
+ struct page *page, int bit_nr,
+ int state, bool lock)
{
struct wait_page_queue wait_page;
wait_queue_entry_t *wait = &wait_page.wait;
@@ -1174,7 +1176,8 @@ EXPORT_SYMBOL_GPL(add_page_wait_queue);
* being cleared, but a memory barrier should be unneccssary since it is
* in the same byte as PG_locked.
*/
-static inline bool clear_bit_unlock_is_negative_byte(long nr, volatile void *mem)
+static inline bool clear_bit_unlock_is_negative_byte(long nr,
+ volatile void *mem)
{
clear_bit_unlock(nr, mem);
/* smp_mb__after_atomic(); */
@@ -1346,8 +1349,8 @@ int __lock_page_or_retry(struct page *page, struct mm_struct *mm,
* index 10, page_cache_next_hole covering both indexes may return 10
* if called under rcu_read_lock.
*/
-pgoff_t page_cache_next_hole(struct address_space *mapping,
- pgoff_t index, unsigned long max_scan)
+pgoff_t page_cache_next_hole(struct address_space *mapping, pgoff_t index,
+ unsigned long max_scan)
{
unsigned long i;
@@ -1387,8 +1390,8 @@ EXPORT_SYMBOL(page_cache_next_hole);
* index 5, page_cache_prev_hole covering both indexes may return 5 if
* called under rcu_read_lock.
*/
-pgoff_t page_cache_prev_hole(struct address_space *mapping,
- pgoff_t index, unsigned long max_scan)
+pgoff_t page_cache_prev_hole(struct address_space *mapping, pgoff_t index,
+ unsigned long max_scan)
{
unsigned long i;
@@ -1533,7 +1536,7 @@ EXPORT_SYMBOL(find_lock_entry);
* If there is a page cache page, it is returned with an increased refcount.
*/
struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,
- int fgp_flags, gfp_t gfp_mask)
+ int fgp_flags, gfp_t gfp_mask)
{
struct page *page;
@@ -1569,7 +1572,8 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,
no_page:
if (!page && (fgp_flags & FGP_CREAT)) {
int err;
- if ((fgp_flags & FGP_WRITE) && mapping_cap_account_dirty(mapping))
+ if ((fgp_flags & FGP_WRITE) &&
+ mapping_cap_account_dirty(mapping))
gfp_mask |= __GFP_WRITE;
if (fgp_flags & FGP_NOFS)
gfp_mask &= ~__GFP_FS;
@@ -1621,9 +1625,9 @@ EXPORT_SYMBOL(pagecache_get_page);
* find_get_entries() returns the number of pages and shadow entries
* which were found.
*/
-unsigned find_get_entries(struct address_space *mapping,
- pgoff_t start, unsigned int nr_entries,
- struct page **entries, pgoff_t *indices)
+unsigned find_get_entries(struct address_space *mapping, pgoff_t start,
+ unsigned int nr_entries, struct page **entries,
+ pgoff_t *indices)
{
void **slot;
unsigned int ret = 0;
@@ -1633,9 +1637,9 @@ unsigned find_get_entries(struct address_space *mapping,
return 0;
rcu_read_lock();
- radix_tree_for_each_slot(slot, &mapping->i_pages, &iter, start) {
+ radix_tree_for_each_slot (slot, &mapping->i_pages, &iter, start) {
struct page *head, *page;
-repeat:
+ repeat:
page = radix_tree_deref_slot(slot);
if (unlikely(!page))
continue;
@@ -1667,8 +1671,7 @@ unsigned find_get_entries(struct address_space *mapping,
put_page(head);
goto repeat;
}
-export:
- indices[ret] = iter.index;
+ export : indices[ret] = iter.index;
entries[ret] = page;
if (++ret == nr_entries)
break;
@@ -1710,12 +1713,12 @@ unsigned find_get_pages_range(struct address_space *mapping, pgoff_t *start,
return 0;
rcu_read_lock();
- radix_tree_for_each_slot(slot, &mapping->i_pages, &iter, *start) {
+ radix_tree_for_each_slot (slot, &mapping->i_pages, &iter, *start) {
struct page *head, *page;
if (iter.index > end)
break;
-repeat:
+ repeat:
page = radix_tree_deref_slot(slot);
if (unlikely(!page))
continue;
@@ -1795,9 +1798,9 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index,
return 0;
rcu_read_lock();
- radix_tree_for_each_contig(slot, &mapping->i_pages, &iter, index) {
+ radix_tree_for_each_contig (slot, &mapping->i_pages, &iter, index) {
struct page *head, *page;
-repeat:
+ repeat:
page = radix_tree_deref_slot(slot);
/* The hole, there no reason to continue */
if (unlikely(!page))
@@ -1837,7 +1840,8 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index,
* otherwise we can get both false positives and false
* negatives, which is just confusing to the caller.
*/
- if (page->mapping == NULL || page_to_pgoff(page) != iter.index) {
+ if (page->mapping == NULL ||
+ page_to_pgoff(page) != iter.index) {
put_page(page);
break;
}
@@ -1864,8 +1868,8 @@ EXPORT_SYMBOL(find_get_pages_contig);
* @tag. We update @index to index the next page for the traversal.
*/
unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index,
- pgoff_t end, int tag, unsigned int nr_pages,
- struct page **pages)
+ pgoff_t end, int tag, unsigned int nr_pages,
+ struct page **pages)
{
struct radix_tree_iter iter;
void **slot;
@@ -1875,12 +1879,13 @@ unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index,
return 0;
rcu_read_lock();
- radix_tree_for_each_tagged(slot, &mapping->i_pages, &iter, *index, tag) {
+ radix_tree_for_each_tagged (slot, &mapping->i_pages, &iter, *index,
+ tag) {
struct page *head, *page;
if (iter.index > end)
break;
-repeat:
+ repeat:
page = radix_tree_deref_slot(slot);
if (unlikely(!page))
continue;
@@ -1957,8 +1962,8 @@ EXPORT_SYMBOL(find_get_pages_range_tag);
* @tag.
*/
unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t start,
- int tag, unsigned int nr_entries,
- struct page **entries, pgoff_t *indices)
+ int tag, unsigned int nr_entries,
+ struct page **entries, pgoff_t *indices)
{
void **slot;
unsigned int ret = 0;
@@ -1968,9 +1973,10 @@ unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t start,
return 0;
rcu_read_lock();
- radix_tree_for_each_tagged(slot, &mapping->i_pages, &iter, start, tag) {
+ radix_tree_for_each_tagged (slot, &mapping->i_pages, &iter, start,
+ tag) {
struct page *head, *page;
-repeat:
+ repeat:
page = radix_tree_deref_slot(slot);
if (unlikely(!page))
continue;
@@ -2003,8 +2009,7 @@ unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t start,
put_page(head);
goto repeat;
}
-export:
- indices[ret] = iter.index;
+ export : indices[ret] = iter.index;
entries[ret] = page;
if (++ret == nr_entries)
break;
@@ -2030,7 +2035,7 @@ EXPORT_SYMBOL(find_get_entries_tag);
* It is going insane. Fix it by quickly scaling down the readahead size.
*/
static void shrink_readahead_size_eio(struct file *filp,
- struct file_ra_state *ra)
+ struct file_ra_state *ra)
{
ra->ra_pages /= 4;
}
@@ -2048,7 +2053,8 @@ static void shrink_readahead_size_eio(struct file *filp,
* of the logic when it comes to error handling etc.
*/
static ssize_t generic_file_buffered_read(struct kiocb *iocb,
- struct iov_iter *iter, ssize_t written)
+ struct iov_iter *iter,
+ ssize_t written)
{
struct file *filp = iocb->ki_filp;
struct address_space *mapping = filp->f_mapping;
@@ -2058,7 +2064,7 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
pgoff_t index;
pgoff_t last_index;
pgoff_t prev_index;
- unsigned long offset; /* offset into pagecache page */
+ unsigned long offset; /* offset into pagecache page */
unsigned int prev_offset;
int error = 0;
@@ -2068,8 +2074,8 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
index = *ppos >> PAGE_SHIFT;
prev_index = ra->prev_pos >> PAGE_SHIFT;
- prev_offset = ra->prev_pos & (PAGE_SIZE-1);
- last_index = (*ppos + iter->count + PAGE_SIZE-1) >> PAGE_SHIFT;
+ prev_offset = ra->prev_pos & (PAGE_SIZE - 1);
+ last_index = (*ppos + iter->count + PAGE_SIZE - 1) >> PAGE_SHIFT;
offset = *ppos & ~PAGE_MASK;
for (;;) {
@@ -2079,7 +2085,7 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
unsigned long nr, ret;
cond_resched();
-find_page:
+ find_page:
if (fatal_signal_pending(current)) {
error = -EINTR;
goto out;
@@ -2089,17 +2095,15 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
if (!page) {
if (iocb->ki_flags & IOCB_NOWAIT)
goto would_block;
- page_cache_sync_readahead(mapping,
- ra, filp,
- index, last_index - index);
+ page_cache_sync_readahead(mapping, ra, filp, index,
+ last_index - index);
page = find_get_page(mapping, index);
if (unlikely(page == NULL))
goto no_cached_page;
}
if (PageReadahead(page)) {
- page_cache_async_readahead(mapping,
- ra, filp, page,
- index, last_index - index);
+ page_cache_async_readahead(mapping, ra, filp, page,
+ index, last_index - index);
}
if (!PageUptodate(page)) {
if (iocb->ki_flags & IOCB_NOWAIT) {
@@ -2119,7 +2123,7 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
goto page_ok;
if (inode->i_blkbits == PAGE_SHIFT ||
- !mapping->a_ops->is_partially_uptodate)
+ !mapping->a_ops->is_partially_uptodate)
goto page_not_up_to_date;
/* pipes can't handle partially uptodate pages */
if (unlikely(iter->type & ITER_PIPE))
@@ -2129,12 +2133,12 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
/* Did it get truncated before we got the lock? */
if (!page->mapping)
goto page_not_up_to_date_locked;
- if (!mapping->a_ops->is_partially_uptodate(page,
- offset, iter->count))
+ if (!mapping->a_ops->is_partially_uptodate(page, offset,
+ iter->count))
goto page_not_up_to_date_locked;
unlock_page(page);
}
-page_ok:
+ page_ok:
/*
* i_size must be checked after we know the page is Uptodate.
*
@@ -2198,13 +2202,13 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
}
continue;
-page_not_up_to_date:
+ page_not_up_to_date:
/* Get exclusive access to the page ... */
error = lock_page_killable(page);
if (unlikely(error))
goto readpage_error;
-page_not_up_to_date_locked:
+ page_not_up_to_date_locked:
/* Did it get truncated before we got the lock? */
if (!page->mapping) {
unlock_page(page);
@@ -2218,7 +2222,7 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
goto page_ok;
}
-readpage:
+ readpage:
/*
* A previous I/O error may have been due to temporary
* failures, eg. multipath errors.
@@ -2260,12 +2264,12 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
goto page_ok;
-readpage_error:
+ readpage_error:
/* UHHUH! A synchronous read error occurred. Report it */
put_page(page);
goto out;
-no_cached_page:
+ no_cached_page:
/*
* Ok, it wasn't cached, so we need to create a new
* page..
@@ -2275,8 +2279,9 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
error = -ENOMEM;
goto out;
}
- error = add_to_page_cache_lru(page, mapping, index,
- mapping_gfp_constraint(mapping, GFP_KERNEL));
+ error = add_to_page_cache_lru(
+ page, mapping, index,
+ mapping_gfp_constraint(mapping, GFP_KERNEL));
if (error) {
put_page(page);
if (error == -EEXIST) {
@@ -2308,8 +2313,7 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
* This is the "read_iter()" routine for all filesystems
* that can use the page cache directly.
*/
-ssize_t
-generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
+ssize_t generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
{
size_t count = iov_iter_count(iter);
ssize_t retval = 0;
@@ -2329,9 +2333,9 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
iocb->ki_pos + count - 1))
return -EAGAIN;
} else {
- retval = filemap_write_and_wait_range(mapping,
- iocb->ki_pos,
- iocb->ki_pos + count - 1);
+ retval = filemap_write_and_wait_range(
+ mapping, iocb->ki_pos,
+ iocb->ki_pos + count - 1);
if (retval < 0)
goto out;
}
@@ -2399,15 +2403,14 @@ static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask)
return ret;
}
-#define MMAP_LOTSAMISS (100)
+#define MMAP_LOTSAMISS (100)
/*
* Synchronous readahead happens when we don't even find
* a page in the page cache at all.
*/
static void do_sync_mmap_readahead(struct vm_area_struct *vma,
- struct file_ra_state *ra,
- struct file *file,
+ struct file_ra_state *ra, struct file *file,
pgoff_t offset)
{
struct address_space *mapping = file->f_mapping;
@@ -2449,10 +2452,8 @@ static void do_sync_mmap_readahead(struct vm_area_struct *vma,
* so we want to possibly extend the readahead further..
*/
static void do_async_mmap_readahead(struct vm_area_struct *vma,
- struct file_ra_state *ra,
- struct file *file,
- struct page *page,
- pgoff_t offset)
+ struct file_ra_state *ra, struct file *file,
+ struct page *page, pgoff_t offset)
{
struct address_space *mapping = file->f_mapping;
@@ -2462,8 +2463,8 @@ static void do_async_mmap_readahead(struct vm_area_struct *vma,
if (ra->mmap_miss > 0)
ra->mmap_miss--;
if (PageReadahead(page))
- page_cache_async_readahead(mapping, ra, file,
- page, offset, ra->ra_pages);
+ page_cache_async_readahead(mapping, ra, file, page, offset,
+ ra->ra_pages);
}
/**
@@ -2500,10 +2501,12 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
pgoff_t max_off;
struct page *page;
vm_fault_t ret = 0;
+ int read_async = 0;
max_off = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
- if (unlikely(offset >= max_off))
+ if (unlikely(offset >= max_off)) {
return VM_FAULT_SIGBUS;
+ }
/*
* Do we have something in the page cache already?
@@ -2515,13 +2518,14 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
* waiting for the lock.
*/
do_async_mmap_readahead(vmf->vma, ra, file, page, offset);
+ read_async = 1;
} else if (!page) {
/* No page in the page cache at all */
do_sync_mmap_readahead(vmf->vma, ra, file, offset);
count_vm_event(PGMAJFAULT);
count_memcg_event_mm(vmf->vma->vm_mm, PGMAJFAULT);
ret = VM_FAULT_MAJOR;
-retry_find:
+ retry_find:
page = find_get_page(mapping, offset);
if (!page)
goto no_cached_page;
@@ -2529,6 +2533,8 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
if (!lock_page_or_retry(page, vmf->vma->vm_mm, vmf->flags)) {
put_page(page);
+ trace_mm_filemap_fsl_read(page, file, 2 + read_async,
+ vmf->address);
return ret | VM_FAULT_RETRY;
}
@@ -2555,10 +2561,12 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
if (unlikely(offset >= max_off)) {
unlock_page(page);
put_page(page);
+ trace_mm_filemap_fsl_read(page, file, 1, vmf->address);
return VM_FAULT_SIGBUS;
}
vmf->page = page;
+ trace_mm_filemap_fsl_read(page, file, 0, vmf->address);
return ret | VM_FAULT_LOCKED;
no_cached_page:
@@ -2581,6 +2589,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
* system is low on memory, or a problem occurs while trying
* to schedule I/O.
*/
+ trace_mm_filemap_fsl_read(page, file, -1, vmf->address);
if (error == -ENOMEM)
return VM_FAULT_OOM;
return VM_FAULT_SIGBUS;
@@ -2606,12 +2615,13 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
/* Things didn't work out. Return zero to tell the mm layer so. */
shrink_readahead_size_eio(file, ra);
+ trace_mm_filemap_fsl_read(page, file, -2, vmf->address);
return VM_FAULT_SIGBUS;
}
EXPORT_SYMBOL(filemap_fault);
-void filemap_map_pages(struct vm_fault *vmf,
- pgoff_t start_pgoff, pgoff_t end_pgoff)
+void filemap_map_pages(struct vm_fault *vmf, pgoff_t start_pgoff,
+ pgoff_t end_pgoff)
{
struct radix_tree_iter iter;
void **slot;
@@ -2622,10 +2632,10 @@ void filemap_map_pages(struct vm_fault *vmf,
struct page *head, *page;
rcu_read_lock();
- radix_tree_for_each_slot(slot, &mapping->i_pages, &iter, start_pgoff) {
+ radix_tree_for_each_slot (slot, &mapping->i_pages, &iter, start_pgoff) {
if (iter.index > end_pgoff)
break;
-repeat:
+ repeat:
page = radix_tree_deref_slot(slot);
if (unlikely(!page))
goto next;
@@ -2653,9 +2663,8 @@ void filemap_map_pages(struct vm_fault *vmf,
goto repeat;
}
- if (!PageUptodate(page) ||
- PageReadahead(page) ||
- PageHWPoison(page))
+ if (!PageUptodate(page) || PageReadahead(page) ||
+ PageHWPoison(page))
goto skip;
if (!trylock_page(page))
goto skip;
@@ -2678,11 +2687,11 @@ void filemap_map_pages(struct vm_fault *vmf,
goto unlock;
unlock_page(page);
goto next;
-unlock:
+ unlock:
unlock_page(page);
-skip:
+ skip:
put_page(page);
-next:
+ next:
/* Huge page is mapped? No need to proceed. */
if (pmd_trans_huge(*vmf->pmd))
break;
@@ -2720,14 +2729,14 @@ vm_fault_t filemap_page_mkwrite(struct vm_fault *vmf)
}
const struct vm_operations_struct generic_file_vm_ops = {
- .fault = filemap_fault,
- .map_pages = filemap_map_pages,
- .page_mkwrite = filemap_page_mkwrite,
+ .fault = filemap_fault,
+ .map_pages = filemap_map_pages,
+ .page_mkwrite = filemap_page_mkwrite,
};
/* This is used for a general mmap of a disk file */
-int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
+int generic_file_mmap(struct file *file, struct vm_area_struct *vma)
{
struct address_space *mapping = file->f_mapping;
@@ -2752,11 +2761,11 @@ int filemap_page_mkwrite(struct vm_fault *vmf)
{
return -ENOSYS;
}
-int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
+int generic_file_mmap(struct file *file, struct vm_area_struct *vma)
{
return -ENOSYS;
}
-int generic_file_readonly_mmap(struct file * file, struct vm_area_struct * vma)
+int generic_file_readonly_mmap(struct file *file, struct vm_area_struct *vma)
{
return -ENOSYS;
}
@@ -2779,10 +2788,9 @@ static struct page *wait_on_page_read(struct page *page)
}
static struct page *do_read_cache_page(struct address_space *mapping,
- pgoff_t index,
- int (*filler)(void *, struct page *),
- void *data,
- gfp_t gfp)
+ pgoff_t index,
+ int (*filler)(void *, struct page *),
+ void *data, gfp_t gfp)
{
struct page *page;
int err;
@@ -2801,7 +2809,7 @@ static struct page *do_read_cache_page(struct address_space *mapping,
return ERR_PTR(err);
}
-filler:
+ filler:
err = filler(data, page);
if (err < 0) {
put_page(page);
@@ -2885,12 +2893,11 @@ static struct page *do_read_cache_page(struct address_space *mapping,
*
* If the page does not get brought uptodate, return -EIO.
*/
-struct page *read_cache_page(struct address_space *mapping,
- pgoff_t index,
- int (*filler)(void *, struct page *),
- void *data)
+struct page *read_cache_page(struct address_space *mapping, pgoff_t index,
+ int (*filler)(void *, struct page *), void *data)
{
- return do_read_cache_page(mapping, index, filler, data, mapping_gfp_mask(mapping));
+ return do_read_cache_page(mapping, index, filler, data,
+ mapping_gfp_mask(mapping));
}
EXPORT_SYMBOL(read_cache_page);
@@ -2905,9 +2912,8 @@ EXPORT_SYMBOL(read_cache_page);
*
* If the page does not get brought uptodate, return -EIO.
*/
-struct page *read_cache_page_gfp(struct address_space *mapping,
- pgoff_t index,
- gfp_t gfp)
+struct page *read_cache_page_gfp(struct address_space *mapping, pgoff_t index,
+ gfp_t gfp)
{
filler_t *filler = (filler_t *)mapping->a_ops->readpage;
@@ -2953,7 +2959,7 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from)
* LFS rule
*/
if (unlikely(pos + iov_iter_count(from) > MAX_NON_LFS &&
- !(file->f_flags & O_LARGEFILE))) {
+ !(file->f_flags & O_LARGEFILE))) {
if (pos >= MAX_NON_LFS)
return -EFBIG;
iov_iter_truncate(from, MAX_NON_LFS - (unsigned long)pos);
@@ -2975,19 +2981,18 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from)