All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Dan Streetman <ddstreet@ieee.org>,
	Yu Zhao <yuzhao@google.com>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Minchan Kim <minchan@kernel.org>,
	Dan Streetman <dan.streetman@canonical.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>
Subject: [PATCH 4.4 28/87] mm/zswap: use workqueue to destroy pool
Date: Mon, 15 Jan 2018 13:34:27 +0100	[thread overview]
Message-ID: <20180115123352.109540787@linuxfoundation.org> (raw)
In-Reply-To: <20180115123349.252309699@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dan Streetman <ddstreet@ieee.org>

commit 200867af4dedfe7cb707f96773684de1d1fd21e6 upstream.

Add a work_struct to struct zswap_pool, and change __zswap_pool_empty to
use the workqueue instead of using call_rcu().

When zswap destroys a pool no longer in use, it uses call_rcu() to
perform the destruction/freeing.  Since that executes in softirq
context, it must not sleep.  However, actually destroying the pool
involves freeing the per-cpu compressors (which requires locking the
cpu_add_remove_lock mutex) and freeing the zpool, for which the
implementation may sleep (e.g.  zsmalloc calls kmem_cache_destroy, which
locks the slab_mutex).  So if either mutex is currently taken, or any
other part of the compressor or zpool implementation sleeps, it will
result in a BUG().

It's not easy to reproduce this when changing zswap's params normally.
In testing with a loaded system, this does not fail:

  $ cd /sys/module/zswap/parameters
  $ echo lz4 > compressor ; echo zsmalloc > zpool

nor does this:

  $ while true ; do
  > echo lzo > compressor ; echo zbud > zpool
  > sleep 1
  > echo lz4 > compressor ; echo zsmalloc > zpool
  > sleep 1
  > done

although it's still possible either of those might fail, depending on
whether anything else besides zswap has locked the mutexes.

However, changing a parameter with no delay immediately causes the
schedule while atomic BUG:

  $ while true ; do
  > echo lzo > compressor ; echo lz4 > compressor
  > done

This is essentially the same as Yu Zhao's proposed patch to zsmalloc,
but moved to zswap, to cover compressor and zpool freeing.

Fixes: f1c54846ee45 ("zswap: dynamic pool creation")
Signed-off-by: Dan Streetman <ddstreet@ieee.org>
Reported-by: Yu Zhao <yuzhao@google.com>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Dan Streetman <dan.streetman@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/zswap.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -123,7 +123,7 @@ struct zswap_pool {
 	struct crypto_comp * __percpu *tfm;
 	struct kref kref;
 	struct list_head list;
-	struct rcu_head rcu_head;
+	struct work_struct work;
 	struct notifier_block notifier;
 	char tfm_name[CRYPTO_MAX_ALG_NAME];
 };
@@ -667,9 +667,11 @@ static int __must_check zswap_pool_get(s
 	return kref_get_unless_zero(&pool->kref);
 }
 
-static void __zswap_pool_release(struct rcu_head *head)
+static void __zswap_pool_release(struct work_struct *work)
 {
-	struct zswap_pool *pool = container_of(head, typeof(*pool), rcu_head);
+	struct zswap_pool *pool = container_of(work, typeof(*pool), work);
+
+	synchronize_rcu();
 
 	/* nobody should have been able to get a kref... */
 	WARN_ON(kref_get_unless_zero(&pool->kref));
@@ -689,7 +691,9 @@ static void __zswap_pool_empty(struct kr
 	WARN_ON(pool == zswap_pool_current());
 
 	list_del_rcu(&pool->list);
-	call_rcu(&pool->rcu_head, __zswap_pool_release);
+
+	INIT_WORK(&pool->work, __zswap_pool_release);
+	schedule_work(&pool->work);
 
 	spin_unlock(&zswap_pools_lock);
 }

  parent reply	other threads:[~2018-01-15 12:39 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15 12:33 [PATCH 4.4 00/87] 4.4.112-stable review Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 01/87] dm bufio: fix shrinker scans when (nr_to_scan < retain_target) Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 02/87] KVM: Fix stack-out-of-bounds read in write_mmio Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 03/87] can: gs_usb: fix return value of the "set_bittiming" callback Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 04/87] IB/srpt: Disable RDMA access by the initiator Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 05/87] MIPS: Validate PR_SET_FP_MODE prctl(2) requests against the ABI of the task Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 06/87] MIPS: Factor out NT_PRFPREG regset access helpers Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 07/87] MIPS: Guard against any partial write attempt with PTRACE_SETREGSET Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 08/87] MIPS: Consistently handle buffer counter " Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 09/87] MIPS: Fix an FCSR access API regression with NT_PRFPREG and MSA Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 10/87] MIPS: Also verify sizeof `elf_fpreg_t with PTRACE_SETREGSET Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 11/87] MIPS: Disallow outsized PTRACE_SETREGSET NT_PRFPREG regset accesses Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 12/87] net/mac80211/debugfs.c: prevent build failure with CONFIG_UBSAN=y Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 13/87] kvm: vmx: Scrub hardware GPRs at VM-exit Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 14/87] x86/vsdo: Fix build on PARAVIRT_CLOCK=y, KVM_GUEST=n Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 15/87] x86/acpi: Handle SCI interrupts above legacy space gracefully Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 16/87] iommu/arm-smmu-v3: Dont free page table ops twice Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 17/87] ALSA: pcm: Remove incorrect snd_BUG_ON() usages Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 18/87] ALSA: pcm: Add missing error checks in OSS emulation plugin builder Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 19/87] ALSA: pcm: Abort properly at pending signal in OSS read/write loops Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 20/87] ALSA: pcm: Allow aborting mutex lock at " Greg Kroah-Hartman
2018-01-23 23:35   ` Ben Hutchings
2018-02-12  8:34     ` Takashi Iwai
2018-02-14 16:20       ` Ben Hutchings
2018-02-14 16:43         ` Takashi Iwai
2018-01-15 12:34 ` [PATCH 4.4 21/87] ALSA: aloop: Release cable upon open error path Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 22/87] ALSA: aloop: Fix inconsistent format due to incomplete rule Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 23/87] ALSA: aloop: Fix racy hw constraints adjustment Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 24/87] x86/acpi: Reduce code duplication in mp_override_legacy_irq() Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 25/87] mm/compaction: fix invalid free_pfn and compact_cached_free_pfn Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 26/87] mm/compaction: pass only pageblock aligned range to pageblock_pfn_to_page Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 27/87] mm/page-writeback: fix dirty_ratelimit calculation Greg Kroah-Hartman
2018-01-15 12:34 ` Greg Kroah-Hartman [this message]
2018-01-15 12:34 ` [PATCH 4.4 29/87] zswap: dont param_set_charp while holding spinlock Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 30/87] locks: dont check for race with close when setting OFD lock Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 31/87] futex: Replace barrier() in unqueue_me() with READ_ONCE() Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 32/87] locking/mutex: Allow next waiter lockless wakeup Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 33/87] [media] usbvision fix overflow of interfaces array Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 34/87] usb: musb: ux500: Fix NULL pointer dereference at system PM Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 35/87] r8152: fix the wake event Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 36/87] r8152: use test_and_clear_bit Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 37/87] r8152: adjust ALDPS function Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 38/87] lan78xx: use skb_cow_head() to deal with cloned skbs Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 39/87] sr9700: " Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 40/87] smsc75xx: " Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 41/87] cx82310_eth: " Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 42/87] x86/mm/pat, /dev/mem: Remove superfluous error message Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 43/87] hwrng: core - sleep interruptible in read Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 44/87] sysrq: Fix warning in sysrq generated crash Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 45/87] xhci: Fix ring leak in failure path of xhci_alloc_virt_device() Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 46/87] Revert "userfaultfd: selftest: vm: allow to build in vm/ directory" Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 47/87] x86/pti/efi: broken conversion from efi to kernel page table Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 48/87] 8021q: fix a memory leak for VLAN 0 device Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 49/87] ip6_tunnel: disable dst caching if tunnel is dual-stack Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 50/87] net: core: fix module type in sock_diag_bind Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 51/87] RDS: Heap OOB write in rds_message_alloc_sgs() Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 52/87] RDS: null pointer dereference in rds_atomic_free_op Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 53/87] sh_eth: fix TSU resource handling Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 54/87] sh_eth: fix SH7757 GEther initialization Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 55/87] net: stmmac: enable EEE in MII, GMII or RGMII only Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 56/87] ipv6: fix possible mem leaks in ipv6_make_skb() Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 57/87] crypto: algapi - fix NULL dereference in crypto_remove_spawns() Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 58/87] rbd: set max_segments to USHRT_MAX Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 59/87] x86/microcode/intel: Extend BDW late-loading with a revision check Greg Kroah-Hartman
2018-01-15 12:34 ` [PATCH 4.4 60/87] KVM: x86: Add memory barrier on vmcs field lookup Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 61/87] drm/vmwgfx: Potential off by one in vmw_view_add() Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 62/87] kaiser: Set _PAGE_NX only if supported Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 63/87] bpf: add bpf_patch_insn_single helper Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 64/87] bpf: dont (ab)use instructions to store state Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 65/87] bpf: move fixup_bpf_calls() function Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 66/87] bpf: refactor fixup_bpf_calls() Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 67/87] bpf: adjust insn_aux_data when patching insns Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 68/87] bpf: prevent out-of-bounds speculation Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 69/87] bpf, array: fix overflow in max_entries and undefined behavior in index_mask Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 70/87] iscsi-target: Make TASK_REASSIGN use proper se_cmd->cmd_kref Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 71/87] target: Avoid early CMD_T_PRE_EXECUTE failures during ABORT_TASK Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 72/87] USB: serial: cp210x: add IDs for LifeScan OneTouch Verio IQ Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 73/87] USB: serial: cp210x: add new device ID ELV ALC 8xxx Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 74/87] usb: misc: usb3503: make sure reset is low for at least 100us Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 75/87] USB: fix usbmon BUG trigger Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 76/87] usbip: remove kernel addresses from usb device and urb debug msgs Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 77/87] staging: android: ashmem: fix a race condition in ASHMEM_SET_SIZE ioctl Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 78/87] Bluetooth: Prevent stack info leak from the EFS element Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 79/87] uas: ignore UAS for Norelsys NS1068(X) chips Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 80/87] e1000e: Fix e1000_check_for_copper_link_ich8lan return value Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 81/87] x86/Documentation: Add PTI description Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 82/87] sysfs/cpu: Add vulnerability folder Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 83/87] x86/cpu: Implement CPU vulnerabilites sysfs functions Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 84/87] sysfs/cpu: Fix typos in vulnerability documentation Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 85/87] x86/alternatives: Fix optimize_nops() checking Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 86/87] x86/alternatives: Add missing \n at end of ALTERNATIVE inline asm Greg Kroah-Hartman
2018-01-15 12:35 ` [PATCH 4.4 87/87] selftests/x86: Add test_vsyscall Greg Kroah-Hartman
2018-01-15 13:01 ` [PATCH 4.4 00/87] 4.4.112-stable review Greg Kroah-Hartman
2018-01-15 13:47 ` Greg Kroah-Hartman
2018-01-15 20:24   ` Christoph Biedl
2018-01-15 20:29     ` Christoph Biedl
2018-01-15 16:28 ` kernelci.org bot
2018-01-15 16:39 ` Nathan Chancellor
2018-01-15 16:39   ` Nathan Chancellor
2018-01-15 18:02   ` Greg Kroah-Hartman
2018-01-15 18:02     ` Greg Kroah-Hartman
2018-01-15 21:59 ` Dan Rue
2018-01-16  5:53   ` Greg Kroah-Hartman
2018-01-16 11:22     ` Naresh Kamboju
2018-01-16 12:15       ` Greg Kroah-Hartman
2018-01-16 14:29 ` Guenter Roeck
2018-01-16 20:24 ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180115123352.109540787@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=dan.streetman@canonical.com \
    --cc=ddstreet@ieee.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=vbabka@suse.cz \
    --cc=yuzhao@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.