From patchwork Tue Jun 9 18:40:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 482332 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id EAFA0140562 for ; Wed, 10 Jun 2015 04:46:34 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932910AbbFISqa (ORCPT ); Tue, 9 Jun 2015 14:46:30 -0400 Received: from mail-ig0-f176.google.com ([209.85.213.176]:37541 "EHLO mail-ig0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932511AbbFISq1 (ORCPT ); Tue, 9 Jun 2015 14:46:27 -0400 Received: by igbsb11 with SMTP id sb11so17335727igb.0 for ; Tue, 09 Jun 2015 11:46:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=a2mS+uH1+7bfrx4VO786aJ0QIZMDClv5h0QMrIK8/18=; b=UTgDBBBgKtfQz5oTEpTRU+p4DJ6KVCOTYpwm6jOQNAJgGOA5JJKzmhOmUh6CiDQhGA u4Mx0kHbyfvairYESAfnmzM5alqzv7OQbXtQXy0DQDitXilrKDuvSF+lAMh+KWyjMiLn LXdFnn/Py1saVGd9RPgYIy2WA6DcclpnJcEzuZmAPhXscXxGX8/NPfUepyLmJX3a8kuq 9m33ulvMZdEAlRwyBsPLCE69xQ1Pl0vsbRztbDcHacvWnXPYswb1FDg1qj8VTKp8UObC NY9fGBW7Fp9xSpKQPvN16iFfhtf6XTUzDdVHgz3QNAkYJub/QGZ9P5xBzmqoEtIm5vze J0+w== X-Gm-Message-State: ALoCoQkNVArzAomQKBLpCa13oVGnCmnEKJAapKTKkgQFzCNX1jixpmftZbpd4Apynt3Pt3Iy9Rb/ X-Received: by 10.107.27.7 with SMTP id b7mr27632130iob.64.1433875214025; Tue, 09 Jun 2015 11:40:14 -0700 (PDT) Received: from tlielax.poochiereds.net ([2606:a000:1105:8e:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id d81sm4429284ioe.12.2015.06.09.11.40.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jun 2015 11:40:12 -0700 (PDT) From: Jeff Layton X-Google-Original-From: Jeff Layton To: trond.myklebust@primarydata.com Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, mgorman@suse.de, linux-mm@kvack.org Subject: [PATCH] net, swap: Remove a warning and clarify why sk_mem_reclaim is required when deactivating swap Date: Tue, 9 Jun 2015 14:40:04 -0400 Message-Id: <1433875204-18060-1-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.2 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Mel Gorman Jeff Layton reported the following; [ 74.232485] ------------[ cut here ]------------ [ 74.233354] WARNING: CPU: 2 PID: 754 at net/core/sock.c:364 sk_clear_memalloc+0x51/0x80() [ 74.234790] Modules linked in: cts rpcsec_gss_krb5 nfsv4 dns_resolver nfs fscache xfs libcrc32c snd_hda_codec_generic snd_hda_intel snd_hda_controller snd_hda_codec snd_hda_core snd_hwdep snd_seq snd_seq_device nfsd snd_pcm snd_timer snd e1000 ppdev parport_pc joydev parport pvpanic soundcore floppy serio_raw i2c_piix4 pcspkr nfs_acl lockd virtio_balloon acpi_cpufreq auth_rpcgss grace sunrpc qxl drm_kms_helper ttm drm virtio_console virtio_blk virtio_pci ata_generic virtio_ring pata_acpi virtio [ 74.243599] CPU: 2 PID: 754 Comm: swapoff Not tainted 4.1.0-rc6+ #5 [ 74.244635] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 74.245546] 0000000000000000 0000000079e69e31 ffff8800d066bde8 ffffffff8179263d [ 74.246786] 0000000000000000 0000000000000000 ffff8800d066be28 ffffffff8109e6fa [ 74.248175] 0000000000000000 ffff880118d48000 ffff8800d58f5c08 ffff880036e380a8 [ 74.249483] Call Trace: [ 74.249872] [] dump_stack+0x45/0x57 [ 74.250703] [] warn_slowpath_common+0x8a/0xc0 [ 74.251655] [] warn_slowpath_null+0x1a/0x20 [ 74.252585] [] sk_clear_memalloc+0x51/0x80 [ 74.253519] [] xs_disable_swap+0x42/0x80 [sunrpc] [ 74.254537] [] rpc_clnt_swap_deactivate+0x7e/0xc0 [sunrpc] [ 74.255610] [] nfs_swap_deactivate+0x27/0x30 [nfs] [ 74.256582] [] destroy_swap_extents+0x74/0x80 [ 74.257496] [] SyS_swapoff+0x222/0x5c0 [ 74.258318] [] ? syscall_trace_leave+0xc7/0x140 [ 74.259253] [] system_call_fastpath+0x12/0x71 [ 74.260158] ---[ end trace 2530722966429f10 ]--- The warning in question was unnecessary but with Jeff's series the rules are also clearer. This patch removes the warning and updates the comment to explain why sk_mem_reclaim() may still be called. Signed-off-by: Mel Gorman Acked-by: Jeff Layton --- net/core/sock.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index 292f42228bfb..2bb4c56370e5 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -354,14 +354,12 @@ void sk_clear_memalloc(struct sock *sk) /* * SOCK_MEMALLOC is allowed to ignore rmem limits to ensure forward - * progress of swapping. However, if SOCK_MEMALLOC is cleared while - * it has rmem allocations there is a risk that the user of the - * socket cannot make forward progress due to exceeding the rmem - * limits. By rights, sk_clear_memalloc() should only be called - * on sockets being torn down but warn and reset the accounting if - * that assumption breaks. + * progress of swapping. SOCK_MEMALLOC may be cleared while + * it has rmem allocations due to the last swapfile being deactivated + * but there is a risk that the socket is unusable due to exceeding + * the rmem limits. Reclaim the reserves and obey rmem limits again. */ - if (WARN_ON(sk->sk_forward_alloc)) + if (sk->sk_forward_alloc) sk_mem_reclaim(sk); } EXPORT_SYMBOL_GPL(sk_clear_memalloc);