1. 12 4月, 2017 4 次提交
  2. 11 4月, 2017 10 次提交
    • T
      perf pmu: Refactor wordwrap() with ltrim() · aa4beb10
      Taeung Song 提交于
      Signed-off-by: NTaeung Song <treeze.taeung@gmail.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1491575061-704-5-git-send-email-treeze.taeung@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      aa4beb10
    • T
      perf ui browser: Refactor the code to parse color configs with ltrim() · e21600fd
      Taeung Song 提交于
      When parsing {fore, back} ground color configs, use ltrim() instead of
      just while loop and isspace().
      Signed-off-by: NTaeung Song <treeze.taeung@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1491575061-704-4-git-send-email-treeze.taeung@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e21600fd
    • T
      perf stat: Refactor the code to strip csv output with ltrim() · b07c40df
      Taeung Song 提交于
      To strip csv output, use ltrim() instead of just while loop and
      isspace() at print_metric_{only}_csv().
      Signed-off-by: NTaeung Song <treeze.taeung@gmail.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1491575061-704-3-git-send-email-treeze.taeung@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b07c40df
    • J
      perf evsel: Return exact sub event which failed with EPERM for wildcards · 32ccb130
      Jin Yao 提交于
      The kernel has a special check for a specific irq_vectors trace event.
      
      TRACE_EVENT_PERF_PERM(irq_work_exit,
      	is_sampling_event(p_event) ? -EPERM : 0);
      
      The perf-record fails for this irq_vectors event when it is present,
      like when using a wildcard:
      
        root@skl:/tmp# perf record -a -e irq_vectors:* sleep 2
        Error:
        You may not have permission to collect system-wide stats.
      
        Consider tweaking /proc/sys/kernel/perf_event_paranoid,
        which controls use of the performance events system by
        unprivileged users (without CAP_SYS_ADMIN).
      
        The current value is 2:
      
          -1: Allow use of (almost) all events by all users
        >= 0: Disallow raw tracepoint access by users without CAP_IOC_LOCK
        >= 1: Disallow CPU event access by users without CAP_SYS_ADMIN
        >= 2: Disallow kernel profiling by users without CAP_SYS_ADMIN
      
        To make this setting permanent, edit /etc/sysctl.conf too, e.g.:
      
              kernel.perf_event_paranoid = -1
      
      This patch prints out the exact sub event that failed with EPERM for
      wildcards to help in understanding what went wrong when this event is
      present:
      
      After the patch:
      
        root@skl:/tmp# perf record -a -e irq_vectors:* sleep 2
        Error:
        No permission to enable irq_vectors:irq_work_exit event.
      
        You may not have permission to collect system-wide stats.
        ......
      
      Committer notes:
      
      So we have a lot of irq_vectors events:
      
        [root@jouet ~]# perf list irq_vectors:*
      
        List of pre-defined events (to be used in -e):
      
          irq_vectors:call_function_entry                    [Tracepoint event]
          irq_vectors:call_function_exit                     [Tracepoint event]
          irq_vectors:call_function_single_entry             [Tracepoint event]
          irq_vectors:call_function_single_exit              [Tracepoint event]
          irq_vectors:deferred_error_apic_entry              [Tracepoint event]
          irq_vectors:deferred_error_apic_exit               [Tracepoint event]
          irq_vectors:error_apic_entry                       [Tracepoint event]
          irq_vectors:error_apic_exit                        [Tracepoint event]
          irq_vectors:irq_work_entry                         [Tracepoint event]
          irq_vectors:irq_work_exit                          [Tracepoint event]
          irq_vectors:local_timer_entry                      [Tracepoint event]
          irq_vectors:local_timer_exit                       [Tracepoint event]
          irq_vectors:reschedule_entry                       [Tracepoint event]
          irq_vectors:reschedule_exit                        [Tracepoint event]
          irq_vectors:spurious_apic_entry                    [Tracepoint event]
          irq_vectors:spurious_apic_exit                     [Tracepoint event]
          irq_vectors:thermal_apic_entry                     [Tracepoint event]
          irq_vectors:thermal_apic_exit                      [Tracepoint event]
          irq_vectors:threshold_apic_entry                   [Tracepoint event]
          irq_vectors:threshold_apic_exit                    [Tracepoint event]
          irq_vectors:x86_platform_ipi_entry                 [Tracepoint event]
          irq_vectors:x86_platform_ipi_exit                  [Tracepoint event]
        #
      
      And some may be sampled:
      
        [root@jouet ~]# perf record -e irq_vectors:local* sleep 20s
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.020 MB perf.data (2 samples) ]
        [root@jouet ~]# perf report -D | egrep 'stats:|events:'
        Aggregated stats:
                   TOTAL events:        155
                    MMAP events:        144
                    COMM events:          2
                    EXIT events:          1
                  SAMPLE events:          2
                   MMAP2 events:          4
          FINISHED_ROUND events:          1
               TIME_CONV events:          1
        irq_vectors:local_timer_entry stats:
                   TOTAL events:          1
                  SAMPLE events:          1
        irq_vectors:local_timer_exit stats:
                   TOTAL events:          1
                  SAMPLE events:          1
        [root@jouet ~]#
      
      But, as shown in the tracepoint definition at the start of this message,
      some, like "irq_vectors:irq_work_exit", may not be sampled, just counted,
      i.e. if we try to sample, as when using 'perf record', we get an error:
      
        [root@jouet ~]# perf record -e irq_vectors:irq_work_exit
        Error:
        You may not have permission to collect system-wide stats.
      
        Consider tweaking /proc/sys/kernel/perf_event_paranoid,
      <SNIP>
      
      The error message is misleading, this patch will help in pointing out
      what is the event causing such an error, but the error message needs
      improvement, i.e. we need to figure out a way to check if a tracepoint
      is counting only, like this one, when all we can do is to count it with
      'perf stat', at most printing the delta using interval printing, as in:
      
         [root@jouet ~]# perf stat -I 5000 -e irq_vectors:irq_work_*
        #           time             counts unit events
             5.000168871                  0      irq_vectors:irq_work_entry
             5.000168871                  0      irq_vectors:irq_work_exit
            10.000676730                  0      irq_vectors:irq_work_entry
            10.000676730                  0      irq_vectors:irq_work_exit
            15.001122415                  0      irq_vectors:irq_work_entry
            15.001122415                  0      irq_vectors:irq_work_exit
            20.001298051                  0      irq_vectors:irq_work_entry
            20.001298051                  0      irq_vectors:irq_work_exit
            25.001485020                  1      irq_vectors:irq_work_entry
            25.001485020                  1      irq_vectors:irq_work_exit
            30.001658706                  0      irq_vectors:irq_work_entry
            30.001658706                  0      irq_vectors:irq_work_exit
        ^C    32.045711878                  0      irq_vectors:irq_work_entry
            32.045711878                  0      irq_vectors:irq_work_exit
      
        [root@jouet ~]#
      
      But at least, when we use a wildcard, this patch helps a bit.
      Signed-off-by: NYao Jin <yao.jin@linux.intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1491566932-503-1-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      32ccb130
    • A
      perf script: Use strtok_r() when parsing output field list · 49346e85
      Arnaldo Carvalho de Melo 提交于
      Just avoiding non-reentrant functions.
      
      Cc: David Ahern <dsahern@gmail.com>
      Link: http://lkml.kernel.org/n/tip-eqytykipd74epzl9aexvppcg@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      49346e85
    • A
      perf callchains: Switch from strtok() to strtok_r() when parsing options · dadafc31
      Arnaldo Carvalho de Melo 提交于
      Trying to keep everything reentrant.
      
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/n/tip-rdce0p2k9e1b4qnrb8ki9mtf@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      dadafc31
    • B
      perf/amd/uncore: Fix pr_fmt() prefix · 9df9078e
      Borislav Petkov 提交于
      Make it "perf/amd/uncore: ", i.e., something more specific than "perf: ".
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: http://lkml.kernel.org/r/20170410122047.3026-4-bp@alien8.de
      [ Changed it to perf/amd/uncore/ ]
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      9df9078e
    • B
      perf/amd/uncore: Clean up per-family setup · 68e80380
      Borislav Petkov 提交于
      Fam16h is the same as the default one, remove it. Turn the switch-case
      into a simple if-else.
      
      No functionality change.
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: http://lkml.kernel.org/r/20170410122047.3026-3-bp@alien8.deSigned-off-by: NIngo Molnar <mingo@kernel.org>
      68e80380
    • B
      perf/amd/uncore: Do feature check first, before assignments · c2628f90
      Borislav Petkov 提交于
      ... and save some unnecessary work. Remove now unused label while at it.
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: http://lkml.kernel.org/r/20170410122047.3026-2-bp@alien8.deSigned-off-by: NIngo Molnar <mingo@kernel.org>
      c2628f90
    • I
      Merge tag 'v4.11-rc6' into perf/core, to pick up fixes · 84b1e36a
      Ingo Molnar 提交于
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      84b1e36a
  3. 10 4月, 2017 5 次提交
    • L
      Linux 4.11-rc6 · 39da7c50
      Linus Torvalds 提交于
      39da7c50
    • L
      Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6 · 84ced7fd
      Linus Torvalds 提交于
      Pull CIFS fixes from Steve French:
       "This is a set of CIFS/SMB3 fixes for stable.
      
        There is another set of four SMB3 reconnect fixes for stable in
        progress but they are still being reviewed/tested, so didn't want to
        wait any longer to send these five below"
      
      * 'for-next' of git://git.samba.org/sfrench/cifs-2.6:
        Reset TreeId to zero on SMB2 TREE_CONNECT
        CIFS: Fix build failure with smb2
        Introduce cifs_copy_file_range()
        SMB3: Rename clone_range to copychunk_range
        Handle mismatched open calls
      84ced7fd
    • L
      Merge branch 'fixes' of git://git.armlinux.org.uk/~rmk/linux-arm · 462e9a35
      Linus Torvalds 提交于
      Pull ARM fixes from Russell King:
       "A number of ARM fixes:
      
         - prevent oopses caused by dma_get_sgtable() and declared DMA
           coherent memory
      
         - fix boot failure on nommu caused by ID_PFR1 access
      
         - a number of kprobes fixes from Jon Medhurst and Masami Hiramatsu"
      
      * 'fixes' of git://git.armlinux.org.uk/~rmk/linux-arm:
        ARM: 8665/1: nommu: access ID_PFR1 only if CPUID scheme
        ARM: dma-mapping: disallow dma_get_sgtable() for non-kernel managed memory
        arm: kprobes: Align stack to 8-bytes in test code
        arm: kprobes: Fix the return address of multiple kretprobes
        arm: kprobes: Skip single-stepping in recursing path if possible
        arm: kprobes: Allow to handle reentered kprobe on single-stepping
      462e9a35
    • L
      Merge tag 'driver-core-4.11-rc6' of... · 5b50be74
      Linus Torvalds 提交于
      Merge tag 'driver-core-4.11-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
      
      Pull driver core fixes from Greg KH:
       "Here are 3 small fixes for 4.11-rc6.
      
        One resolves a reported issue with sysfs files that NeilBrown found,
        one is a documenatation fix for the stable kernel rules, and the last
        is a small MAINTAINERS file update for kernfs"
      
      * tag 'driver-core-4.11-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
        MAINTAINERS: separate out kernfs maintainership
        sysfs: be careful of error returns from ops->show()
        Documentation: stable-kernel-rules: fix stable-tag format
      5b50be74
    • L
      Merge tag 'staging-4.11-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging · 62e1fd08
      Linus Torvalds 提交于
      Pull staging/IIO driver rfixes from Greg KH:
       "Here are a number of small IIO and staging driver fixes for 4.11-rc6.
        Nothing big here, just iio fixes for reported issues, and an ashmem
        fix for a very old bug that has been reported by a number of Android
        vendors"
      
      * tag 'staging-4.11-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
        staging: android: ashmem: lseek failed due to no FMODE_LSEEK.
        iio: hid-sensor-attributes: Fix sensor property setting failure.
        iio: accel: hid-sensor-accel-3d: Fix duplicate scan index error
        iio: core: Fix IIO_VAL_FRACTIONAL_LOG2 for negative values
        iio: st_pressure: initialize lps22hb bootime
        iio: bmg160: reset chip when probing
        iio: cros_ec_sensors: Fix return value to get raw and calibbias data.
      62e1fd08
  4. 09 4月, 2017 7 次提交
    • L
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · 2a610b8a
      Linus Torvalds 提交于
      Pull VFS fixes from Al Viro:
       "statx followup fixes and a fix for stack-smashing on alpha"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
        alpha: fix stack smashing in old_adjtimex(2)
        statx: Include a mask for stx_attributes in struct statx
        statx: Reserve the top bit of the mask for future struct expansion
        xfs: report crtime and attribute flags to statx
        ext4: Add statx support
        statx: optimize copy of struct statx to userspace
        statx: remove incorrect part of vfs_statx() comment
        statx: reject unknown flags when using NULL path
        Documentation/filesystems: fix documentation for ->getattr()
      2a610b8a
    • L
      Merge branch 'for-linus' of git://git.kernel.dk/linux-block · 78d91a75
      Linus Torvalds 提交于
      Pull block fixes from Jens Axboe:
       "Here's a pull request for 4.11-rc, fixing a set of issues mostly
        centered around the new scheduling framework. These have been brewing
        for a while, but split up into what we absolutely need in 4.11, and
        what we can defer until 4.12. These are well tested, on both single
        queue and multiqueue setups, and with and without shared tags. They
        fix several hangs that have happened in testing.
      
        This is obviously larger than I would have preferred at this point in
        time, but I don't think we can shave much off this and still get the
        desired results.
      
        In detail, this pull request contains:
      
         - a set of five fixes for NVMe, mostly from Christoph and one from
           Roland.
      
         - a series from Bart, fixing issues with dm-mq and SCSI shared tags
           and scheduling. Note that one of those patches commit messages may
           read like an optimization, but it is in fact an important fix for
           queue restarts in particular.
      
         - a series from Omar, most importantly fixing a hang with multiple
           hardware queues when we fail to get a driver tag. Another important
           fix in there is for resizing hardware queues, which nbd does when
           handling multiple sockets for one connection.
      
         - fixing an imbalance in putting the ctx for hctx request allocations
           from Minchan"
      
      * 'for-linus' of git://git.kernel.dk/linux-block:
        blk-mq: Restart a single queue if tag sets are shared
        dm rq: Avoid that request processing stalls sporadically
        scsi: Avoid that SCSI queues get stuck
        blk-mq: Introduce blk_mq_delay_run_hw_queue()
        blk-mq: remap queues when adding/removing hardware queues
        blk-mq-sched: fix crash in switch error path
        blk-mq-sched: set up scheduler tags when bringing up new queues
        blk-mq-sched: refactor scheduler initialization
        blk-mq: use the right hctx when getting a driver tag fails
        nvmet: fix byte swap in nvmet_parse_io_cmd
        nvmet: fix byte swap in nvmet_execute_write_zeroes
        nvmet: add missing byte swap in nvmet_get_smart_log
        nvme: add missing byte swap in nvme_setup_discard
        nvme: Correct NVMF enum values to match NVMe-oF rev 1.0
        block: do not put mq context in blk_mq_alloc_request_hctx
      78d91a75
    • L
      Merge tag 'pinctrl-v4.11-4' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl · c3df1c7c
      Linus Torvalds 提交于
      Pull pin control fix from Linus Walleij:
       "This late fix for pin control is hopefully the last I send this cycle.
      
        The problem was detected early in the v4.11 release cycle and there
        has been some back and forth on how to solve it. Sadly the proper fix
        arrives late, but at least not too late.
      
        An issue was detected with pin control on the Freescale i.MX after the
        refactorings for more general group and function handling.
      
        We now have the proper fix for this"
      
      * tag 'pinctrl-v4.11-4' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
        pinctrl: core: Fix pinctrl_register_and_init() with pinctrl_enable()
      c3df1c7c
    • L
      Merge tag 'powerpc-4.11-7' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux · 894ca30c
      Linus Torvalds 提交于
      Pull powerpc fixes from Michael Ellerman:
       "Some more powerpc fixes for 4.11:
      
        Headed to stable:
      
         - disable HFSCR[TM] if TM is not supported, fixes a potential host
           kernel crash triggered by a hostile guest, but only in
           configurations that no one uses
      
         - don't try to fix up misaligned load-with-reservation instructions
      
         - fix flush_(d|i)cache_range() called from modules on little endian
           kernels
      
         - add missing global TLB invalidate if cxl is active
      
         - fix missing preempt_disable() in crc32c-vpmsum
      
        And a fix for selftests build changes that went in this release:
      
         - selftests/powerpc: Fix standalone powerpc build
      
        Thanks to: Benjamin Herrenschmidt, Frederic Barrat, Oliver O'Halloran,
        Paul Mackerras"
      
      * tag 'powerpc-4.11-7' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
        powerpc/crypto/crc32c-vpmsum: Fix missing preempt_disable()
        powerpc/mm: Add missing global TLB invalidate if cxl is active
        powerpc/64: Fix flush_(d|i)cache_range() called from modules
        powerpc: Don't try to fix up misaligned load-with-reservation instructions
        powerpc: Disable HFSCR[TM] if TM is not supported
        selftests/powerpc: Fix standalone powerpc build
      894ca30c
    • C
      mm/mempolicy.c: fix error handling in set_mempolicy and mbind. · cf01fb99
      Chris Salls 提交于
      In the case that compat_get_bitmap fails we do not want to copy the
      bitmap to the user as it will contain uninitialized stack data and leak
      sensitive data.
      Signed-off-by: NChris Salls <salls@cs.ucsb.edu>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      cf01fb99
    • L
      sysctl: report EINVAL if value is larger than UINT_MAX for proc_douintvec · 425fffd8
      Liping Zhang 提交于
      Currently, inputting the following command will succeed but actually the
      value will be truncated:
      
        # echo 0x12ffffffff > /proc/sys/net/ipv4/tcp_notsent_lowat
      
      This is not friendly to the user, so instead, we should report error
      when the value is larger than UINT_MAX.
      
      Fixes: e7d316a0 ("sysctl: handle error writing UINT_MAX to u32 fields")
      Signed-off-by: NLiping Zhang <zlpnobody@gmail.com>
      Cc: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      425fffd8
    • T
      MAINTAINERS: separate out kernfs maintainership · 27f395b8
      Tejun Heo 提交于
      Separate out kernfs from driver core and add myself as a
      co-maintainer.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      27f395b8
  5. 08 4月, 2017 14 次提交
    • N
      sysfs: be careful of error returns from ops->show() · c8a139d0
      NeilBrown 提交于
      ops->show() can return a negative error code.
      Commit 65da3484 ("sysfs: correctly handle short reads on PREALLOC attrs.")
      (in v4.4) caused this to be stored in an unsigned 'size_t' variable, so errors
      would look like large numbers.
      As a result, if an error is returned, sysfs_kf_read() will return the
      value of 'count', typically 4096.
      
      Commit 17d0774f ("sysfs: correctly handle read offset on PREALLOC attrs")
      (in v4.8) extended this error to use the unsigned large 'len' as a size for
      memmove().
      Consequently, if ->show returns an error, then the first read() on the
      sysfs file will return 4096 and could return uninitialized memory to
      user-space.
      If the application performs a subsequent read, this will trigger a memmove()
      with extremely large count, and is likely to crash the machine is bizarre ways.
      
      This bug can currently only be triggered by reading from an md
      sysfs attribute declared with __ATTR_PREALLOC() during the
      brief period between when mddev_put() deletes an mddev from
      the ->all_mddevs list, and when mddev_delayed_delete() - which is
      scheduled on a workqueue - completes.
      Before this, an error won't be returned by the ->show()
      After this, the ->show() won't be called.
      
      I can reproduce it reliably only by putting delay like
      	usleep_range(500000,700000);
      early in mddev_delayed_delete(). Then after creating an
      md device md0 run
        echo clear > /sys/block/md0/md/array_state; cat /sys/block/md0/md/array_state
      
      The bug can be triggered without the usleep.
      
      Fixes: 65da3484 ("sysfs: correctly handle short reads on PREALLOC attrs.")
      Fixes: 17d0774f ("sysfs: correctly handle read offset on PREALLOC attrs")
      Cc: stable@vger.kernel.org
      Signed-off-by: NNeilBrown <neilb@suse.com>
      Acked-by: NTejun Heo <tj@kernel.org>
      Reported-and-tested-by: NMiroslav Benes <mbenes@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c8a139d0
    • J
      Documentation: stable-kernel-rules: fix stable-tag format · cf903e9d
      Johan Hovold 提交于
      A patch documenting how to specify which kernels a particular fix should
      be backported to (seemingly) inadvertently added a minus sign after the
      kernel version. This particular stable-tag format had never been used
      prior to this patch, and was neither present when the patch in question
      was first submitted (it was added in v2 without any comment).
      
      Drop the minus sign to avoid any confusion.
      
      Fixes: fdc81b79 ("stable_kernel_rules: Add clause about specification of kernel versions to patch.")
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cf903e9d
    • S
      staging: android: ashmem: lseek failed due to no FMODE_LSEEK. · 97fbfef6
      Shuxiao Zhang 提交于
      vfs_llseek will check whether the file mode has
      FMODE_LSEEK, no return failure. But ashmem can be
      lseek, so add FMODE_LSEEK to ashmem file.
      
      Comment From Greg Hackmann:
      	ashmem_llseek() passes the llseek() call through to the backing
      	shmem file.  91360b02 ("ashmem: use vfs_llseek()") changed
      	this from directly calling the file's llseek() op into a VFS
      	layer call.  This also adds a check for the FMODE_LSEEK bit, so
      	without that bit ashmem_llseek() now always fails with -ESPIPE.
      
      Fixes: 91360b02 ("ashmem: use vfs_llseek()")
      Signed-off-by: NShuxiao Zhang <zhangshuxiao@xiaomi.com>
      Tested-by: NGreg Hackmann <ghackmann@google.com>
      Cc: stable <stable@vger.kernel.org> # 3.18+
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      97fbfef6
    • L
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc · 8b65bb57
      Linus Torvalds 提交于
      Pull sparc fixes from David Miller:
       "Several fixes here, mostly having to due with either build errors or
        memory corruptions depending upon whether you have THP enabled or not"
      
      * git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc:
        sparc: remove unused wp_works_ok macro
        sparc32: Export vac_cache_size to fix build error
        sparc64: Fix memory corruption when THP is enabled
        sparc64: Fix kernel panic due to erroneous #ifdef surrounding pmd_write()
        arch/sparc: Avoid DCTI Couples
        sparc64: kern_addr_valid regression
        sparc64: Add support for 2G hugepages
        sparc64: Fix size check in huge_pte_alloc
      8b65bb57
    • L
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 542380a2
      Linus Torvalds 提交于
      Pull KVM fixes from Radim Krčmář:
       "ARM:
         - Fix a problem with GICv3 userspace save/restore
         - Clarify GICv2 userspace save/restore ABI
         - Be more careful in clearing GIC LRs
         - Add missing synchronization primitive to our MMU handling code
      
        PPC:
         - Check for a NULL return from kzalloc
      
        s390:
         - Prevent translation exception errors on valid page tables for the
           instruction-exection-protection support
      
        x86:
         - Fix Page-Modification Logging when running a nested guest"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: PPC: Book3S HV: Check for kmalloc errors in ioctl
        KVM: nVMX: initialize PML fields in vmcs02
        KVM: nVMX: do not leak PML full vmexit to L1
        KVM: arm/arm64: vgic: Fix GICC_PMR uaccess on GICv3 and clarify ABI
        KVM: arm64: Ensure LRs are clear when they should be
        kvm: arm/arm64: Fix locking for kvm_free_stage2_pgd
        KVM: s390: remove change-recording override support
        arm/arm64: KVM: Take mmap_sem in kvm_arch_prepare_memory_region
        arm/arm64: KVM: Take mmap_sem in stage2_unmap_vm
      542380a2
    • L
      Merge branch 'stable-4.11' of git://git.infradead.org/users/pcmoore/audit · 62fedca5
      Linus Torvalds 提交于
      Pull audit cleanup from Paul Moore:
       "A week later than I had hoped, but as promised, here is the audit
        uninline-fix we talked about during the last audit pull request.
      
        The patch is slightly different than what we originally discussed as
        it made more sense to keep the audit_signal_info() function in
        auditsc.c rather than move it and bunch of other related
        variables/definitions into audit.c/audit.h.
      
        At some point in the future I need to look at how the audit code is
        organized across kernel/audit*, I suspect we could do things a bit
        better, but it doesn't seem like a -rc release is a good place for
        that ;)
      
        Regardless, this patch passes our tests without problem and looks good
        for v4.11"
      
      * 'stable-4.11' of git://git.infradead.org/users/pcmoore/audit:
        audit: move audit_signal_info() into kernel/auditsc.c
      62fedca5
    • L
      Merge branch 'akpm' (patches from Andrew) · 56c29979
      Linus Torvalds 提交于
      Merge misc fixes from Andrew Morton:
       "10 fixes"
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>:
        mm: move pcp and lru-pcp draining into single wq
        mailmap: update Yakir Yang email address
        mm, swap_cgroup: reschedule when neeed in swap_cgroup_swapoff()
        dax: fix radix tree insertion race
        mm, thp: fix setting of defer+madvise thp defrag mode
        ptrace: fix PTRACE_LISTEN race corrupting task->state
        vmlinux.lds: add missing VMLINUX_SYMBOL macros
        mm/page_alloc.c: fix print order in show_free_areas()
        userfaultfd: report actual registered features in fdinfo
        mm: fix page_vma_mapped_walk() for ksm pages
      56c29979
    • M
      mm: move pcp and lru-pcp draining into single wq · ce612879
      Michal Hocko 提交于
      We currently have 2 specific WQ_RECLAIM workqueues in the mm code.
      vmstat_wq for updating pcp stats and lru_add_drain_wq dedicated to drain
      per cpu lru caches.  This seems more than necessary because both can run
      on a single WQ.  Both do not block on locks requiring a memory
      allocation nor perform any allocations themselves.  We will save one
      rescuer thread this way.
      
      On the other hand drain_all_pages() queues work on the system wq which
      doesn't have rescuer and so this depend on memory allocation (when all
      workers are stuck allocating and new ones cannot be created).
      
      Initially we thought this would be more of a theoretical problem but
      Hugh Dickins has reported:
      
      : 4.11-rc has been giving me hangs after hours of swapping load.  At
      : first they looked like memory leaks ("fork: Cannot allocate memory");
      : but for no good reason I happened to do "cat /proc/sys/vm/stat_refresh"
      : before looking at /proc/meminfo one time, and the stat_refresh stuck
      : in D state, waiting for completion of flush_work like many kworkers.
      : kthreadd waiting for completion of flush_work in drain_all_pages().
      
      This worker should be using WQ_RECLAIM as well in order to guarantee a
      forward progress.  We can reuse the same one as for lru draining and
      vmstat.
      
      Link: http://lkml.kernel.org/r/20170307131751.24936-1-mhocko@kernel.orgSigned-off-by: NMichal Hocko <mhocko@suse.com>
      Suggested-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Acked-by: NVlastimil Babka <vbabka@suse.cz>
      Acked-by: NMel Gorman <mgorman@suse.de>
      Tested-by: NYang Li <pku.leo@gmail.com>
      Tested-by: NHugh Dickins <hughd@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ce612879
    • J
      mailmap: update Yakir Yang email address · cdcf4330
      Jeffy Chen 提交于
      Set current email address to replace previous employers email addresses.
      
      Link: http://lkml.kernel.org/r/1491450722-6633-1-git-send-email-jeffy.chen@rock-chips.comSigned-off-by: NJeffy Chen <jeffy.chen@rock-chips.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      cdcf4330
    • D
      mm, swap_cgroup: reschedule when neeed in swap_cgroup_swapoff() · 460bcec8
      David Rientjes 提交于
      We got need_resched() warnings in swap_cgroup_swapoff() because
      swap_cgroup_ctrl[type].length is particularly large.
      
      Reschedule when needed.
      
      Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1704061315270.80559@chino.kir.corp.google.comSigned-off-by: NDavid Rientjes <rientjes@google.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      460bcec8
    • R
      dax: fix radix tree insertion race · e11f8b7b
      Ross Zwisler 提交于
      While running generic/340 in my test setup I hit the following race.  It
      can happen with kernels that support FS DAX PMDs, so v4.10 thru
      v4.11-rc5.
      
      Thread 1				Thread 2
      --------				--------
      dax_iomap_pmd_fault()
        grab_mapping_entry()
          spin_lock_irq()
          get_unlocked_mapping_entry()
          'entry' is NULL, can't call lock_slot()
          spin_unlock_irq()
          radix_tree_preload()
      					dax_iomap_pmd_fault()
      					  grab_mapping_entry()
      					    spin_lock_irq()
      					    get_unlocked_mapping_entry()
      					    ...
      					    lock_slot()
      					    spin_unlock_irq()
      					  dax_pmd_insert_mapping()
      					    <inserts a PMD mapping>
          spin_lock_irq()
          __radix_tree_insert() fails with -EEXIST
          <fall back to 4k fault, and die horribly
           when inserting a 4k entry where a PMD exists>
      
      The issue is that we have to drop mapping->tree_lock while calling
      radix_tree_preload(), but since we didn't have a radix tree entry to
      lock (unlike in the pmd_downgrade case) we have no protection against
      Thread 2 coming along and inserting a PMD at the same index.  For 4k
      entries we handled this with a special-case response to -EEXIST coming
      from the __radix_tree_insert(), but this doesn't save us for PMDs
      because the -EEXIST case can also mean that we collided with a 4k entry
      in the radix tree at a different index, but one that is covered by our
      PMD range.
      
      So, correctly handle both the 4k and 2M collision cases by explicitly
      re-checking the radix tree for an entry at our index once we reacquire
      mapping->tree_lock.
      
      This patch has made it through a clean xfstests run with the current
      v4.11-rc5 based linux/master, and it also ran generic/340 500 times in a
      loop.  It used to fail within the first 10 iterations.
      
      Link: http://lkml.kernel.org/r/20170406212944.2866-1-ross.zwisler@linux.intel.comSigned-off-by: NRoss Zwisler <ross.zwisler@linux.intel.com>
      Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Matthew Wilcox <mawilcox@microsoft.com>
      Cc: <stable@vger.kernel.org>    [4.10+]
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e11f8b7b
    • D
      mm, thp: fix setting of defer+madvise thp defrag mode · 4fad7fb6
      David Rientjes 提交于
      Setting thp defrag mode of "defer+madvise" actually sets "defer" in the
      kernel due to the name similarity and the out-of-order way the string is
      checked in defrag_store().
      
      Check the string in the correct order so that
      TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG is set appropriately for
      "defer+madvise".
      
      Fixes: 21440d7e ("mm, thp: add new defer+madvise defrag option")
      Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1704051814420.137626@chino.kir.corp.google.comSigned-off-by: NDavid Rientjes <rientjes@google.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Acked-by: NVlastimil Babka <vbabka@suse.cz>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4fad7fb6
    • B
      ptrace: fix PTRACE_LISTEN race corrupting task->state · 5402e97a
      bsegall@google.com 提交于
      In PT_SEIZED + LISTEN mode STOP/CONT signals cause a wakeup against
      __TASK_TRACED.  If this races with the ptrace_unfreeze_traced at the end
      of a PTRACE_LISTEN, this can wake the task /after/ the check against
      __TASK_TRACED, but before the reset of state to TASK_TRACED.  This
      causes it to instead clobber TASK_WAKING, allowing a subsequent wakeup
      against TRACED while the task is still on the rq wake_list, corrupting
      it.
      
      Oleg said:
       "The kernel can crash or this can lead to other hard-to-debug problems.
        In short, "task->state = TASK_TRACED" in ptrace_unfreeze_traced()
        assumes that nobody else can wake it up, but PTRACE_LISTEN breaks the
        contract. Obviusly it is very wrong to manipulate task->state if this
        task is already running, or WAKING, or it sleeps again"
      
      [akpm@linux-foundation.org: coding-style fixes]
      Fixes: 9899d11f ("ptrace: ensure arch_ptrace/ptrace_request can never race with SIGKILL")
      Link: http://lkml.kernel.org/r/xm26y3vfhmkp.fsf_-_@bsegall-linux.mtv.corp.google.comSigned-off-by: NBen Segall <bsegall@google.com>
      Acked-by: NOleg Nesterov <oleg@redhat.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5402e97a
    • J
      vmlinux.lds: add missing VMLINUX_SYMBOL macros · d79bf21e
      Jessica Yu 提交于
      When __{start,end}_ro_after_init is referenced from C code, we run into
      the following build errors on blackfin:
      
        kernel/extable.c:169: undefined reference to `__start_ro_after_init'
        kernel/extable.c:169: undefined reference to `__end_ro_after_init'
      
      The build error is due to the fact that blackfin is one of the few
      arches that prepends an underscore '_' to all symbols defined in C.
      
      Fix this by wrapping __{start,end}_ro_after_init in vmlinux.lds.h with
      VMLINUX_SYMBOL(), which adds the necessary prefix for arches that have
      HAVE_UNDERSCORE_SYMBOL_PREFIX.
      
      Link: http://lkml.kernel.org/r/1491259387-15869-1-git-send-email-jeyu@redhat.comSigned-off-by: NJessica Yu <jeyu@redhat.com>
      Acked-by: NKees Cook <keescook@chromium.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Eddie Kovsky <ewk@edkovsky.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d79bf21e