~ubuntu-branches/debian/experimental/linux-tools/experimental

« back to all changes in this revision

Viewing changes to include/linux/sched.h

  • Committer: Package Import Robot
  • Author(s): Ben Hutchings
  • Date: 2014-02-02 16:57:49 UTC
  • mfrom: (1.1.10) (0.1.21 sid)
  • Revision ID: package-import@ubuntu.com-20140202165749-tw94o9t1t0a8txk6
Tags: 3.13-1~exp2
Merge changes from sid up to 3.12.6-3

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <linux/errno.h>
23
23
#include <linux/nodemask.h>
24
24
#include <linux/mm_types.h>
 
25
#include <linux/preempt_mask.h>
25
26
 
26
27
#include <asm/page.h>
27
28
#include <asm/ptrace.h>
285
286
}
286
287
#endif
287
288
 
 
289
#ifdef CONFIG_DETECT_HUNG_TASK
 
290
void reset_hung_task_detector(void);
 
291
#else
 
292
static inline void reset_hung_task_detector(void)
 
293
{
 
294
}
 
295
#endif
 
296
 
288
297
/* Attach to any functions which should be ignored in wchan output. */
289
298
#define __sched         __attribute__((__section__(".sched.text")))
290
299
 
322
331
extern void set_dumpable(struct mm_struct *mm, int value);
323
332
extern int get_dumpable(struct mm_struct *mm);
324
333
 
 
334
#define SUID_DUMP_DISABLE       0       /* No setuid dumping */
 
335
#define SUID_DUMP_USER          1       /* Dump as user of process */
 
336
#define SUID_DUMP_ROOT          2       /* Dump as root */
 
337
 
325
338
/* mm flags */
326
339
/* dumpable bits */
327
340
#define MMF_DUMPABLE      0  /* core dump is permitted */
427
440
                .sum_exec_runtime = 0,                          \
428
441
        }
429
442
 
 
443
#ifdef CONFIG_PREEMPT_COUNT
 
444
#define PREEMPT_DISABLED        (1 + PREEMPT_ENABLED)
 
445
#else
 
446
#define PREEMPT_DISABLED        PREEMPT_ENABLED
 
447
#endif
 
448
 
430
449
/*
431
450
 * Disable preemption until the scheduler is running.
432
451
 * Reset by start_kernel()->sched_init()->init_idle().
434
453
 * We include PREEMPT_ACTIVE to avoid cond_resched() from working
435
454
 * before the scheduler is active -- see should_resched().
436
455
 */
437
 
#define INIT_PREEMPT_COUNT      (1 + PREEMPT_ACTIVE)
 
456
#define INIT_PREEMPT_COUNT      (PREEMPT_DISABLED + PREEMPT_ACTIVE)
438
457
 
439
458
/**
440
459
 * struct thread_group_cputimer - thread group interval timer counts
768
787
#define SD_ASYM_PACKING         0x0800  /* Place busy groups earlier in the domain */
769
788
#define SD_PREFER_SIBLING       0x1000  /* Prefer to place tasks in a sibling domain */
770
789
#define SD_OVERLAP              0x2000  /* sched_domains of this level overlap */
 
790
#define SD_NUMA                 0x4000  /* cross-node balancing */
771
791
 
772
792
extern int __weak arch_sd_sibiling_asym_packing(void);
773
793
 
809
829
        unsigned int balance_interval;  /* initialise to 1. units in ms. */
810
830
        unsigned int nr_balance_failed; /* initialise to 0 */
811
831
 
812
 
        u64 last_update;
 
832
        /* idle_balance() stats */
 
833
        u64 max_newidle_lb_cost;
 
834
        unsigned long next_decay_max_lb_cost;
813
835
 
814
836
#ifdef CONFIG_SCHEDSTATS
815
837
        /* load_balance() stats */
908
930
struct uts_namespace;
909
931
 
910
932
struct load_weight {
911
 
        unsigned long weight, inv_weight;
 
933
        unsigned long weight;
 
934
        u32 inv_weight;
912
935
};
913
936
 
914
937
struct sched_avg {
1029
1052
        struct task_struct *last_wakee;
1030
1053
        unsigned long wakee_flips;
1031
1054
        unsigned long wakee_flip_decay_ts;
 
1055
 
 
1056
        int wake_cpu;
1032
1057
#endif
1033
1058
        int on_rq;
1034
1059
 
1046
1071
        struct hlist_head preempt_notifiers;
1047
1072
#endif
1048
1073
 
1049
 
        /*
1050
 
         * fpu_counter contains the number of consecutive context switches
1051
 
         * that the FPU is used. If this is over a threshold, the lazy fpu
1052
 
         * saving becomes unlazy to save the trap. This is an unsigned char
1053
 
         * so that after 256 times the counter wraps and the behavior turns
1054
 
         * lazy again; this to deal with bursty apps that only use FPU for
1055
 
         * a short time
1056
 
         */
1057
 
        unsigned char fpu_counter;
1058
1074
#ifdef CONFIG_BLK_DEV_IO_TRACE
1059
1075
        unsigned int btrace_seq;
1060
1076
#endif
1324
1340
#endif
1325
1341
#ifdef CONFIG_NUMA_BALANCING
1326
1342
        int numa_scan_seq;
1327
 
        int numa_migrate_seq;
1328
1343
        unsigned int numa_scan_period;
 
1344
        unsigned int numa_scan_period_max;
 
1345
        int numa_preferred_nid;
 
1346
        int numa_migrate_deferred;
 
1347
        unsigned long numa_migrate_retry;
1329
1348
        u64 node_stamp;                 /* migration stamp  */
1330
1349
        struct callback_head numa_work;
 
1350
 
 
1351
        struct list_head numa_entry;
 
1352
        struct numa_group *numa_group;
 
1353
 
 
1354
        /*
 
1355
         * Exponential decaying average of faults on a per-node basis.
 
1356
         * Scheduling placement decisions are made based on the these counts.
 
1357
         * The values remain static for the duration of a PTE scan
 
1358
         */
 
1359
        unsigned long *numa_faults;
 
1360
        unsigned long total_numa_faults;
 
1361
 
 
1362
        /*
 
1363
         * numa_faults_buffer records faults per node during the current
 
1364
         * scan window. When the scan completes, the counts in numa_faults
 
1365
         * decay and these values are copied.
 
1366
         */
 
1367
        unsigned long *numa_faults_buffer;
 
1368
 
 
1369
        /*
 
1370
         * numa_faults_locality tracks if faults recorded during the last
 
1371
         * scan window were remote/local. The task scan period is adapted
 
1372
         * based on the locality of the faults with different weights
 
1373
         * depending on whether they were shared or private faults
 
1374
         */
 
1375
        unsigned long numa_faults_locality[2];
 
1376
 
 
1377
        unsigned long numa_pages_migrated;
1331
1378
#endif /* CONFIG_NUMA_BALANCING */
1332
1379
 
1333
1380
        struct rcu_head rcu;
1412
1459
/* Future-safe accessor for struct task_struct's cpus_allowed. */
1413
1460
#define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
1414
1461
 
 
1462
#define TNF_MIGRATED    0x01
 
1463
#define TNF_NO_GROUP    0x02
 
1464
#define TNF_SHARED      0x04
 
1465
#define TNF_FAULT_LOCAL 0x08
 
1466
 
1415
1467
#ifdef CONFIG_NUMA_BALANCING
1416
 
extern void task_numa_fault(int node, int pages, bool migrated);
 
1468
extern void task_numa_fault(int last_node, int node, int pages, int flags);
 
1469
extern pid_t task_numa_group_id(struct task_struct *p);
1417
1470
extern void set_numabalancing_state(bool enabled);
 
1471
extern void task_numa_free(struct task_struct *p);
 
1472
 
 
1473
extern unsigned int sysctl_numa_balancing_migrate_deferred;
1418
1474
#else
1419
 
static inline void task_numa_fault(int node, int pages, bool migrated)
1420
 
{
 
1475
static inline void task_numa_fault(int last_node, int node, int pages,
 
1476
                                   int flags)
 
1477
{
 
1478
}
 
1479
static inline pid_t task_numa_group_id(struct task_struct *p)
 
1480
{
 
1481
        return 0;
1421
1482
}
1422
1483
static inline void set_numabalancing_state(bool enabled)
1423
1484
{
1424
1485
}
 
1486
static inline void task_numa_free(struct task_struct *p)
 
1487
{
 
1488
}
1425
1489
#endif
1426
1490
 
1427
1491
static inline struct pid *task_pid(struct task_struct *task)
1974
2038
#else
1975
2039
 static inline void kick_process(struct task_struct *tsk) { }
1976
2040
#endif
1977
 
extern void sched_fork(struct task_struct *p);
 
2041
extern void sched_fork(unsigned long clone_flags, struct task_struct *p);
1978
2042
extern void sched_dead(struct task_struct *p);
1979
2043
 
1980
2044
extern void proc_caches_init(void);
2401
2465
        return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p);
2402
2466
}
2403
2467
 
2404
 
static inline int need_resched(void)
2405
 
{
2406
 
        return unlikely(test_thread_flag(TIF_NEED_RESCHED));
2407
 
}
2408
 
 
2409
2468
/*
2410
2469
 * cond_resched() and cond_resched_lock(): latency reduction via
2411
2470
 * explicit rescheduling in places that are safe. The return
2474
2533
{
2475
2534
        return task_thread_info(p)->status & TS_POLLING;
2476
2535
}
2477
 
static inline void current_set_polling(void)
 
2536
static inline void __current_set_polling(void)
2478
2537
{
2479
2538
        current_thread_info()->status |= TS_POLLING;
2480
2539
}
2481
2540
 
2482
 
static inline void current_clr_polling(void)
 
2541
static inline bool __must_check current_set_polling_and_test(void)
 
2542
{
 
2543
        __current_set_polling();
 
2544
 
 
2545
        /*
 
2546
         * Polling state must be visible before we test NEED_RESCHED,
 
2547
         * paired by resched_task()
 
2548
         */
 
2549
        smp_mb();
 
2550
 
 
2551
        return unlikely(tif_need_resched());
 
2552
}
 
2553
 
 
2554
static inline void __current_clr_polling(void)
2483
2555
{
2484
2556
        current_thread_info()->status &= ~TS_POLLING;
2485
 
        smp_mb__after_clear_bit();
 
2557
}
 
2558
 
 
2559
static inline bool __must_check current_clr_polling_and_test(void)
 
2560
{
 
2561
        __current_clr_polling();
 
2562
 
 
2563
        /*
 
2564
         * Polling state must be visible before we test NEED_RESCHED,
 
2565
         * paired by resched_task()
 
2566
         */
 
2567
        smp_mb();
 
2568
 
 
2569
        return unlikely(tif_need_resched());
2486
2570
}
2487
2571
#elif defined(TIF_POLLING_NRFLAG)
2488
2572
static inline int tsk_is_polling(struct task_struct *p)
2489
2573
{
2490
2574
        return test_tsk_thread_flag(p, TIF_POLLING_NRFLAG);
2491
2575
}
2492
 
static inline void current_set_polling(void)
 
2576
 
 
2577
static inline void __current_set_polling(void)
2493
2578
{
2494
2579
        set_thread_flag(TIF_POLLING_NRFLAG);
2495
2580
}
2496
2581
 
2497
 
static inline void current_clr_polling(void)
 
2582
static inline bool __must_check current_set_polling_and_test(void)
 
2583
{
 
2584
        __current_set_polling();
 
2585
 
 
2586
        /*
 
2587
         * Polling state must be visible before we test NEED_RESCHED,
 
2588
         * paired by resched_task()
 
2589
         *
 
2590
         * XXX: assumes set/clear bit are identical barrier wise.
 
2591
         */
 
2592
        smp_mb__after_clear_bit();
 
2593
 
 
2594
        return unlikely(tif_need_resched());
 
2595
}
 
2596
 
 
2597
static inline void __current_clr_polling(void)
2498
2598
{
2499
2599
        clear_thread_flag(TIF_POLLING_NRFLAG);
2500
2600
}
 
2601
 
 
2602
static inline bool __must_check current_clr_polling_and_test(void)
 
2603
{
 
2604
        __current_clr_polling();
 
2605
 
 
2606
        /*
 
2607
         * Polling state must be visible before we test NEED_RESCHED,
 
2608
         * paired by resched_task()
 
2609
         */
 
2610
        smp_mb__after_clear_bit();
 
2611
 
 
2612
        return unlikely(tif_need_resched());
 
2613
}
 
2614
 
2501
2615
#else
2502
2616
static inline int tsk_is_polling(struct task_struct *p) { return 0; }
2503
 
static inline void current_set_polling(void) { }
2504
 
static inline void current_clr_polling(void) { }
 
2617
static inline void __current_set_polling(void) { }
 
2618
static inline void __current_clr_polling(void) { }
 
2619
 
 
2620
static inline bool __must_check current_set_polling_and_test(void)
 
2621
{
 
2622
        return unlikely(tif_need_resched());
 
2623
}
 
2624
static inline bool __must_check current_clr_polling_and_test(void)
 
2625
{
 
2626
        return unlikely(tif_need_resched());
 
2627
}
2505
2628
#endif
2506
2629
 
 
2630
static __always_inline bool need_resched(void)
 
2631
{
 
2632
        return unlikely(tif_need_resched());
 
2633
}
 
2634
 
2507
2635
/*
2508
2636
 * Thread group CPU time accounting.
2509
2637
 */
2545
2673
        return task_thread_info(p)->cpu;
2546
2674
}
2547
2675
 
 
2676
static inline int task_node(const struct task_struct *p)
 
2677
{
 
2678
        return cpu_to_node(task_cpu(p));
 
2679
}
 
2680
 
2548
2681
extern void set_task_cpu(struct task_struct *p, unsigned int cpu);
2549
2682
 
2550
2683
#else