Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2010286imm; Tue, 10 Jul 2018 11:32:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcPITxMrR6XKmU2/C5Y6SmFrUCe4MgfUFlxHWMKi2w9Dm39abKrk75oHMOxe2JL1Mfx1PDg X-Received: by 2002:a63:3686:: with SMTP id d128-v6mr23019222pga.18.1531247548939; Tue, 10 Jul 2018 11:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531247548; cv=none; d=google.com; s=arc-20160816; b=k8Wv6BzZ1dOlXr4k5tf1lOPws4grLJps/3o4NySeTPsdmlm+hKlSj2frZEMADEZnyw g+i5wC4/spMieSTDMvIXv5+cAL/q4KVMXUkNIgwh6Z7VL0x4ynSjTb5+IjN+PxhLbutp rKFNfyj+8tmGWISuO5/XPgFrDIC3xUBjbEH7acDkFyT3lwlQKdYNUm5DFQRH7JQSetAd Q8UabUcW2BPAJSLfflLFH9sr3Vi4XK56znUrCTjjuqxdCFD7atakn8wvvx8f9MFa1pDg 1WDgB9/0Ea2bk473WWGmgGLCMifCX/AhrMnwK+k5drfp97xpDbMbHtIqyuPbmJ0XljU6 4zWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XhM725hjUEjxPNIvC5REPyEIzYLjqtWTpVuTRVDpV4g=; b=kb3XPV9Hnh+iDm464kIrmEvoog0L/BuHExrK/y4y5UyASoTTQPHq2K6gEytCB7IgmS iANyPlOLwkRetZwHfvY+L78c1QCOBFygmM5c/1bXlu4jSr3v0DLYo15u+jUGttNifOxj ysL8hxhoWlws03d70yqIvhijiJ9z44KPgPwmOJa+Z9Da4l/utBnOaDI8N+8JWTFTmRHv hoM6ZDEIOGaDr7k6D/Ux6LBY+whxgHJx7KhO/R1TCaJLNqlhoc+QoBN8aNPCLrnB+uXf x5/BE/TL+vJ6bvYCy/dir4kGWsw5bzBf+7pvMTgo2mQI45Jax7c0Etu/B+yr96Bct2Wh yPhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9-v6si8784562pgc.685.2018.07.10.11.32.13; Tue, 10 Jul 2018 11:32:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388311AbeGJSbQ (ORCPT + 99 others); Tue, 10 Jul 2018 14:31:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45752 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732920AbeGJSbP (ORCPT ); Tue, 10 Jul 2018 14:31:15 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 40B00EC6; Tue, 10 Jul 2018 18:31:03 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Rientjes , Mikulas Patocka , Mike Snitzer Subject: [PATCH 4.9 47/52] dm bufio: dont take the lock in dm_bufio_shrink_count Date: Tue, 10 Jul 2018 20:25:15 +0200 Message-Id: <20180710182453.756938285@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180710182449.285532226@linuxfoundation.org> References: <20180710182449.285532226@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mikulas Patocka 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 Signed-off-by: Mikulas Patocka Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-bufio.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -1598,19 +1598,11 @@ dm_bufio_shrink_scan(struct shrinker *sh static unsigned long dm_bufio_shrink_count(struct shrinker *shrink, struct shrink_control *sc) { - struct dm_bufio_client *c; - unsigned long count; - unsigned long retain_target; + struct dm_bufio_client *c = container_of(shrink, struct dm_bufio_client, shrinker); + unsigned long count = READ_ONCE(c->n_buffers[LIST_CLEAN]) + + READ_ONCE(c->n_buffers[LIST_DIRTY]); + unsigned long retain_target = get_retain_buffers(c); - c = container_of(shrink, struct dm_bufio_client, shrinker); - if (sc->gfp_mask & __GFP_FS) - dm_bufio_lock(c); - else if (!dm_bufio_trylock(c)) - return 0; - - count = c->n_buffers[LIST_CLEAN] + c->n_buffers[LIST_DIRTY]; - retain_target = get_retain_buffers(c); - dm_bufio_unlock(c); return (count < retain_target) ? 0 : (count - retain_target); }