~kleber-souza/ubuntu/+source/linux/+git/xenial:update-to-4.4.140

Last commit made on 2018-07-30
Get this branch:
git clone -b update-to-4.4.140 https://git.launchpad.net/~kleber-souza/ubuntu/+source/linux/+git/xenial
Only Kleber Sacilotto de Souza can upload to this branch. If you are Kleber Sacilotto de Souza please log in for upload directions.

Branch merges

Branch information

Name:
update-to-4.4.140
Repository:
lp:~kleber-souza/ubuntu/+source/linux/+git/xenial

Recent commits

7e3dd9c... by Greg Kroah-Hartman <email address hidden>

Linux 4.4.140

BugLink: https://bugs.launchpad.net/bugs/1784409

Signed-off-by: Kleber Sacilotto de Souza <email address hidden>

0bcda70... by Dan Carpenter <email address hidden>

staging: comedi: quatech_daqp_cs: fix no-op loop daqp_ao_insn_write()

BugLink: https://bugs.launchpad.net/bugs/1784409

commit 1376b0a2160319125c3a2822e8c09bd283cd8141 upstream.

There is a '>' vs '<' typo so this loop is a no-op.

Fixes: d35dcc89fc93 ("staging: comedi: quatech_daqp_cs: fix daqp_ao_insn_write()")
Signed-off-by: Dan Carpenter <email address hidden>
Reviewed-by: Ian Abbott <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>
Signed-off-by: Kleber Sacilotto de Souza <email address hidden>

b990b18... by Jann Horn (corp account)

netfilter: nf_log: don't hold nf_log_mutex during user access

BugLink: https://bugs.launchpad.net/bugs/1784409

commit ce00bf07cc95a57cd20b208e02b3c2604e532ae8 upstream.

The old code would indefinitely block other users of nf_log_mutex if
a userspace access in proc_dostring() blocked e.g. due to a userfaultfd
region. Fix it by moving proc_dostring() out of the locked region.

This is a followup to commit 266d07cb1c9a ("netfilter: nf_log: fix
sleeping function called from invalid context"), which changed this code
from using rcu_read_lock() to taking nf_log_mutex.

Fixes: 266d07cb1c9a ("netfilter: nf_log: fix sleeping function calle[...]")
Signed-off-by: Jann Horn <email address hidden>
Signed-off-by: Pablo Neira Ayuso <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>
Signed-off-by: Kleber Sacilotto de Souza <email address hidden>

f0268eb... by Tokunori Ikegami <email address hidden>

mtd: cfi_cmdset_0002: Change erase functions to check chip good only

BugLink: https://bugs.launchpad.net/bugs/1784409

commit 79ca484b613041ca223f74b34608bb6f5221724b upstream.

Currently the functions use to check both chip ready and good.
But the chip ready is not enough to check the operation status.
So change this to check the chip good instead of this.
About the retry functions to make sure the error handling remain it.

Signed-off-by: Tokunori Ikegami <email address hidden>
Reviewed-by: Joakim Tjernlund <email address hidden>
Cc: Chris Packham <email address hidden>
Cc: Brian Norris <email address hidden>
Cc: David Woodhouse <email address hidden>
Cc: Boris Brezillon <email address hidden>
Cc: Marek Vasut <email address hidden>
Cc: Richard Weinberger <email address hidden>
Cc: Cyrille Pitchen <email address hidden>
Cc: <email address hidden>
Cc: <email address hidden>
Signed-off-by: Boris Brezillon <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>
Signed-off-by: Kleber Sacilotto de Souza <email address hidden>

1de9568... by Tokunori Ikegami <email address hidden>

mtd: cfi_cmdset_0002: Change erase functions to retry for error

BugLink: https://bugs.launchpad.net/bugs/1784409

commit 45f75b8a919a4255f52df454f1ffdee0e42443b2 upstream.

For the word write functions it is retried for error.
But it is not implemented to retry for the erase functions.
To make sure for the erase functions change to retry as same.

This is needed to prevent the flash erase error caused only once.
It was caused by the error case of chip_good() in the do_erase_oneblock().
Also it was confirmed on the MACRONIX flash device MX29GL512FHT2I-11G.
But the error issue behavior is not able to reproduce at this moment.
The flash controller is parallel Flash interface integrated on BCM53003.

Signed-off-by: Tokunori Ikegami <email address hidden>
Reviewed-by: Joakim Tjernlund <email address hidden>
Cc: Chris Packham <email address hidden>
Cc: Brian Norris <email address hidden>
Cc: David Woodhouse <email address hidden>
Cc: Boris Brezillon <email address hidden>
Cc: Marek Vasut <email address hidden>
Cc: Richard Weinberger <email address hidden>
Cc: Cyrille Pitchen <email address hidden>
Cc: <email address hidden>
Cc: <email address hidden>
Signed-off-by: Boris Brezillon <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>
Signed-off-by: Kleber Sacilotto de Souza <email address hidden>

3895cfd... by Tokunori Ikegami <email address hidden>

mtd: cfi_cmdset_0002: Change definition naming to retry write operation

BugLink: https://bugs.launchpad.net/bugs/1784409

commit 85a82e28b023de9b259a86824afbd6ba07bd6475 upstream.

The definition can be used for other program and erase operations also.
So change the naming to MAX_RETRIES from MAX_WORD_RETRIES.

Signed-off-by: Tokunori Ikegami <email address hidden>
Reviewed-by: Joakim Tjernlund <email address hidden>
Cc: Chris Packham <email address hidden>
Cc: Brian Norris <email address hidden>
Cc: David Woodhouse <email address hidden>
Cc: Boris Brezillon <email address hidden>
Cc: Marek Vasut <email address hidden>
Cc: Richard Weinberger <email address hidden>
Cc: Cyrille Pitchen <email address hidden>
Cc: <email address hidden>
Cc: <email address hidden>
Signed-off-by: Boris Brezillon <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>
Signed-off-by: Kleber Sacilotto de Souza <email address hidden>

5dbf566... by Mikulas Patocka <email address hidden>

dm bufio: don't take the lock in dm_bufio_shrink_count

BugLink: https://bugs.launchpad.net/bugs/1784409

commit d12067f428c037b4575aaeb2be00847fc214c24a upstream.

dm_bufio_shrink_count() is called from do_shrink_slab to find out how many
freeable objects are there. The reported value doesn't have to be precise,
so we don't need to take the dm-bufio lock.

Suggested-by: David Rientjes <email address hidden>
Signed-off-by: Mikulas Patocka <email address hidden>
Signed-off-by: Mike Snitzer <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>
Signed-off-by: Kleber Sacilotto de Souza <email address hidden>

a34657f... by Martin Kaiser <email address hidden>

mtd: rawnand: mxc: set spare area size register explicitly

BugLink: https://bugs.launchpad.net/bugs/1784409

commit 3f77f244d8ec28e3a0a81240ffac7d626390060c upstream.

The v21 version of the NAND flash controller contains a Spare Area Size
Register (SPAS) at offset 0x10. Its setting defaults to the maximum
spare area size of 218 bytes. The size that is set in this register is
used by the controller when it calculates the ECC bytes internally in
hardware.

Usually, this register is updated from settings in the IIM fuses when
the system is booting from NAND flash. For other boot media, however,
the SPAS register remains at the default setting, which may not work for
the particular flash chip on the board. The same goes for flash chips
whose configuration cannot be set in the IIM fuses (e.g. chips with 2k
sector size and 128 bytes spare area size can't be configured in the IIM
fuses on imx25 systems).

Set the SPAS register explicitly during the preset operation. Derive the
register value from mtd->oobsize that was detected during probe by
decoding the flash chip's ID bytes.

While at it, rename the define for the spare area register's offset to
NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is
different from the register on v21 controllers.

Fixes: d484018 ("mtd: mxc_nand: set NFC registers after reset")
Cc: <email address hidden>
Signed-off-by: Martin Kaiser <email address hidden>
Reviewed-by: Sascha Hauer <email address hidden>
Reviewed-by: Miquel Raynal <email address hidden>
Signed-off-by: Boris Brezillon <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>
Signed-off-by: Kleber Sacilotto de Souza <email address hidden>

ad5854a... by Mikulas Patocka <email address hidden>

dm bufio: drop the lock when doing GFP_NOIO allocation

BugLink: https://bugs.launchpad.net/bugs/1784409

commit 41c73a49df31151f4ff868f28fe4f129f113fa2c upstream.

If the first allocation attempt using GFP_NOWAIT fails, drop the lock
and retry using GFP_NOIO allocation (lock is dropped because the
allocation can take some time).

Note that we won't do GFP_NOIO allocation when we loop for the second
time, because the lock shouldn't be dropped between __wait_for_free_buffer
and __get_unclaimed_buffer.

Signed-off-by: Mikulas Patocka <email address hidden>
Signed-off-by: Mike Snitzer <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>
Signed-off-by: Kleber Sacilotto de Souza <email address hidden>

57c9e0e... by Douglas Anderson <email address hidden>

dm bufio: avoid sleeping while holding the dm_bufio lock

BugLink: https://bugs.launchpad.net/bugs/1784409

commit 9ea61cac0b1ad0c09022f39fd97e9b99a2cfc2dc upstream.

We've seen in-field reports showing _lots_ (18 in one case, 41 in
another) of tasks all sitting there blocked on:

  mutex_lock+0x4c/0x68
  dm_bufio_shrink_count+0x38/0x78
  shrink_slab.part.54.constprop.65+0x100/0x464
  shrink_zone+0xa8/0x198

In the two cases analyzed, we see one task that looks like this:

  Workqueue: kverityd verity_prefetch_io

  __switch_to+0x9c/0xa8
  __schedule+0x440/0x6d8
  schedule+0x94/0xb4
  schedule_timeout+0x204/0x27c
  schedule_timeout_uninterruptible+0x44/0x50
  wait_iff_congested+0x9c/0x1f0
  shrink_inactive_list+0x3a0/0x4cc
  shrink_lruvec+0x418/0x5cc
  shrink_zone+0x88/0x198
  try_to_free_pages+0x51c/0x588
  __alloc_pages_nodemask+0x648/0xa88
  __get_free_pages+0x34/0x7c
  alloc_buffer+0xa4/0x144
  __bufio_new+0x84/0x278
  dm_bufio_prefetch+0x9c/0x154
  verity_prefetch_io+0xe8/0x10c
  process_one_work+0x240/0x424
  worker_thread+0x2fc/0x424
  kthread+0x10c/0x114

...and that looks to be the one holding the mutex.

The problem has been reproduced on fairly easily:
0. Be running Chrome OS w/ verity enabled on the root filesystem
1. Pick test patch: http://crosreview.com/412360
2. Install launchBalloons.sh and balloon.arm from
     http://crbug.com/468342
   ...that's just a memory stress test app.
3. On a 4GB rk3399 machine, run
     nice ./launchBalloons.sh 4 900 100000
   ...that tries to eat 4 * 900 MB of memory and keep accessing.
4. Login to the Chrome web browser and restore many tabs

With that, I've seen printouts like:
  DOUG: long bufio 90758 ms
...and stack trace always show's we're in dm_bufio_prefetch().

The problem is that we try to allocate memory with GFP_NOIO while
we're holding the dm_bufio lock. Instead we should be using
GFP_NOWAIT. Using GFP_NOIO can cause us to sleep while holding the
lock and that causes the above problems.

The current behavior explained by David Rientjes:

  It will still try reclaim initially because __GFP_WAIT (or
  __GFP_KSWAPD_RECLAIM) is set by GFP_NOIO. This is the cause of
  contention on dm_bufio_lock() that the thread holds. You want to
  pass GFP_NOWAIT instead of GFP_NOIO to alloc_buffer() when holding a
  mutex that can be contended by a concurrent slab shrinker (if
  count_objects didn't use a trylock, this pattern would trivially
  deadlock).

This change significantly increases responsiveness of the system while
in this state. It makes a real difference because it unblocks kswapd.
In the bug report analyzed, kswapd was hung:

   kswapd0 D ffffffc000204fd8 0 72 2 0x00000000
   Call trace:
   [<ffffffc000204fd8>] __switch_to+0x9c/0xa8
   [<ffffffc00090b794>] __schedule+0x440/0x6d8
   [<ffffffc00090bac0>] schedule+0x94/0xb4
   [<ffffffc00090be44>] schedule_preempt_disabled+0x28/0x44
   [<ffffffc00090d900>] __mutex_lock_slowpath+0x120/0x1ac
   [<ffffffc00090d9d8>] mutex_lock+0x4c/0x68
   [<ffffffc000708e7c>] dm_bufio_shrink_count+0x38/0x78
   [<ffffffc00030b268>] shrink_slab.part.54.constprop.65+0x100/0x464
   [<ffffffc00030dbd8>] shrink_zone+0xa8/0x198
   [<ffffffc00030e578>] balance_pgdat+0x328/0x508
   [<ffffffc00030eb7c>] kswapd+0x424/0x51c
   [<ffffffc00023f06c>] kthread+0x10c/0x114
   [<ffffffc000203dd0>] ret_from_fork+0x10/0x40

By unblocking kswapd memory pressure should be reduced.

Suggested-by: David Rientjes <email address hidden>
Reviewed-by: Guenter Roeck <email address hidden>
Signed-off-by: Douglas Anderson <email address hidden>
Signed-off-by: Mike Snitzer <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>
Signed-off-by: Kleber Sacilotto de Souza <email address hidden>