From patchwork Thu Oct 15 14:24:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 11839423 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE10C1744 for ; Thu, 15 Oct 2020 14:26:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3F4F22256 for ; Thu, 15 Oct 2020 14:26:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="HHdCFMYd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388123AbgJOO0E (ORCPT ); Thu, 15 Oct 2020 10:26:04 -0400 Received: from esa5.hc3370-68.iphmx.com ([216.71.155.168]:29824 "EHLO esa5.hc3370-68.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388099AbgJOO0D (ORCPT ); Thu, 15 Oct 2020 10:26:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1602771963; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nec4gD5X3MmxS0I+tIlw7vXxkm0qi/q39D7bqb697+c=; b=HHdCFMYdp3iaiytTJKwwuZXXhBJuVSTxYO1RZ3dMYNibrbr2a4k1Lf8W h36r2U2wmCpY1PXpCQdgw0XxhrRWMt0fkpnKnu9SjBfJJUPvARX99CGGQ MvgBIhO5ITQu2SjW3B1t5gju0nnWS/237zPuSacssCCqCyxuQTl1K7C/e U=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: iDE2yqknkOfC10XRaSF9d4E7CcP5Q7x0CCeK4aQp5Q1/nZv/prDXfC+SlM5ci1UypwQ6cB1QW+ Rl8ICdJBrilb1/wW5SOKfXC43Dd3QJpWshFMC/Mu6GwUhqTT1AsidtLjSrF0UP9RjAgeNOlQ79 8HTIxkcBb2U8ycE40/DnqPu0OXqxHm6i21NwnLMHnvEgjCF+aZN/ES0ZdS0A8AuJi3b9RvwYcM ZD4BGKRh2YA84jLWIu2a3ImyVJs3BdlrheZginPypI7gTI5wlbJDTrAusT9k6r+iiKjqi7gyug CCw= X-SBRS: 2.5 X-MesageID: 29146562 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.77,379,1596513600"; d="scan'208";a="29146562" From: Roger Pau Monne To: CC: Roger Pau Monne , Konrad Rzeszutek Wilk , Jens Axboe , Boris Ostrovsky , SeongJae Park , , , "J . Roeleveld" , =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= Subject: [PATCH 1/2] xen/blkback: turn the cache purge LRU interval into a parameter Date: Thu, 15 Oct 2020 16:24:15 +0200 Message-ID: <20201015142416.70294-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201015142416.70294-1-roger.pau@citrix.com> References: <20201015142416.70294-1-roger.pau@citrix.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Assume that reads and writes to the variable will be atomic. The worse that could happen is that one of the LRU intervals is not calculated properly if a partially written value is read, but that would only be a transient issue. Signed-off-by: Roger Pau Monné --- Cc: Konrad Rzeszutek Wilk Cc: Jens Axboe Cc: Boris Ostrovsky Cc: SeongJae Park Cc: xen-devel@lists.xenproject.org Cc: linux-block@vger.kernel.org Cc: J. Roeleveld Cc: Jürgen Groß --- Documentation/ABI/testing/sysfs-driver-xen-blkback | 10 ++++++++++ drivers/block/xen-blkback/blkback.c | 9 ++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-driver-xen-blkback b/Documentation/ABI/testing/sysfs-driver-xen-blkback index ecb7942ff146..776f25d335ca 100644 --- a/Documentation/ABI/testing/sysfs-driver-xen-blkback +++ b/Documentation/ABI/testing/sysfs-driver-xen-blkback @@ -35,3 +35,13 @@ Description: controls the duration in milliseconds that blkback will not cache any page not backed by a grant mapping. The default is 10ms. + +What: /sys/module/xen_blkback/parameters/lru_internval +Date: October 2020 +KernelVersion: 5.10 +Contact: Roger Pau Monné +Description: + The LRU mechanism to clean the lists of persistent grants needs + to be executed periodically. This parameter controls the time + interval between consecutive executions of the purge mechanism + is set in ms. diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c index adfc9352351d..6ad9b76fdb2b 100644 --- a/drivers/block/xen-blkback/blkback.c +++ b/drivers/block/xen-blkback/blkback.c @@ -117,7 +117,10 @@ MODULE_PARM_DESC(max_ring_page_order, "Maximum order of pages to be used for the * be executed periodically. The time interval between consecutive executions * of the purge mechanism is set in ms. */ -#define LRU_INTERVAL 100 +static unsigned int lru_interval = 100; +module_param_named(lru_interval, lru_interval, uint, 0644); +MODULE_PARM_DESC(lru_internval, + "Time interval between consecutive executions of the cache purge mechanism (in ms)"); /* * When the persistent grants list is full we will remove unused grants @@ -620,7 +623,7 @@ int xen_blkif_schedule(void *arg) if (unlikely(vbd->size != vbd_sz(vbd))) xen_vbd_resize(blkif); - timeout = msecs_to_jiffies(LRU_INTERVAL); + timeout = msecs_to_jiffies(lru_interval); timeout = wait_event_interruptible_timeout( ring->wq, @@ -650,7 +653,7 @@ int xen_blkif_schedule(void *arg) if (blkif->vbd.feature_gnt_persistent && time_after(jiffies, ring->next_lru)) { purge_persistent_gnt(ring); - ring->next_lru = jiffies + msecs_to_jiffies(LRU_INTERVAL); + ring->next_lru = jiffies + msecs_to_jiffies(lru_interval); } /* Shrink the free pages pool if it is too large. */ From patchwork Thu Oct 15 14:24:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 11839419 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AEA2E1744 for ; Thu, 15 Oct 2020 14:25:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82EE92225A for ; Thu, 15 Oct 2020 14:25:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="gnxBu0Ok" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387948AbgJOOZn (ORCPT ); Thu, 15 Oct 2020 10:25:43 -0400 Received: from esa6.hc3370-68.iphmx.com ([216.71.155.175]:16161 "EHLO esa6.hc3370-68.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728231AbgJOOZn (ORCPT ); Thu, 15 Oct 2020 10:25:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1602771942; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qACv2ER1JyTphbaRvO3qjGjCO4Ywxs60QaM06nUJtes=; b=gnxBu0Okljz4KZnafw9fJasKLyJEsI43noBV4BEOOxucWUU4pN1ER84H bjF80Y5hs/1HClri4hmBuq7vFIimhLPWYsvfkPmAYLv9IAnnkQLZXQ4VF CBK2MfO58C+MuosMAyDCt5RM44jKzXObbfPaf1nClUSKdhETtcZa+ZNfq U=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: pc4931EzyhHOF/1+wy2nZ4XleWl7qBYyCEkp00YAxqGPWcnc737w40tXoyYSmGIVRQQH4Iit93 07qxT5ybUOhZ2qxJTCRSoPyXLgFI6SB+kOdkwJ+tnstszy0/PMaQb6jMTptLMYlA/iJY4Lf2Oi F/cLdsnFwau5CJFWfhOyvPnFRV7Fsi+iyINxA6sbSGk67l/81+RiveiaYesCDf5YPxdThZ1AFI ilb1k5+O1Wjm2wOq7NJkhCdFSBqRNJaXSmpoZMT/4v02/Y5YxNBbR02IjhXjykf3zIOuEoFlNN uzc= X-SBRS: 2.5 X-MesageID: 29332243 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.77,379,1596513600"; d="scan'208";a="29332243" From: Roger Pau Monne To: CC: Roger Pau Monne , Konrad Rzeszutek Wilk , Jens Axboe , Boris Ostrovsky , SeongJae Park , , , "J . Roeleveld" , =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= Subject: [PATCH 2/2] xen/blkback: turn the cache purge percent into a parameter Date: Thu, 15 Oct 2020 16:24:16 +0200 Message-ID: <20201015142416.70294-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201015142416.70294-1-roger.pau@citrix.com> References: <20201015142416.70294-1-roger.pau@citrix.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Assume that reads and writes to the variable will be atomic. The worse that could happen is that one of the purges removes a partially written percentage of grants, but the cache itself will recover. Signed-off-by: Roger Pau Monné --- Cc: Konrad Rzeszutek Wilk Cc: Jens Axboe Cc: Boris Ostrovsky Cc: SeongJae Park Cc: xen-devel@lists.xenproject.org Cc: linux-block@vger.kernel.org Cc: J. Roeleveld Cc: Jürgen Groß --- Documentation/ABI/testing/sysfs-driver-xen-blkback | 9 +++++++++ drivers/block/xen-blkback/blkback.c | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-driver-xen-blkback b/Documentation/ABI/testing/sysfs-driver-xen-blkback index 776f25d335ca..7de791ad61f9 100644 --- a/Documentation/ABI/testing/sysfs-driver-xen-blkback +++ b/Documentation/ABI/testing/sysfs-driver-xen-blkback @@ -45,3 +45,12 @@ Description: to be executed periodically. This parameter controls the time interval between consecutive executions of the purge mechanism is set in ms. + +What: /sys/module/xen_blkback/parameters/lru_percent_clean +Date: October 2020 +KernelVersion: 5.10 +Contact: Roger Pau Monné +Description: + When the persistent grants list is full we will remove unused + grants from the list. The percent number of grants to be + removed at each LRU execution. diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c index 6ad9b76fdb2b..772852d45a5a 100644 --- a/drivers/block/xen-blkback/blkback.c +++ b/drivers/block/xen-blkback/blkback.c @@ -127,7 +127,10 @@ MODULE_PARM_DESC(lru_internval, * from the list. The percent number of grants to be removed at each LRU * execution. */ -#define LRU_PERCENT_CLEAN 5 +static unsigned int lru_percent_clean = 5; +module_param_named(lru_percent_clean, lru_percent_clean, uint, 0644); +MODULE_PARM_DESC(lru_percent_clean, + "Percentage of persistent grants to remove from the cache when full"); /* Run-time switchable: /sys/module/blkback/parameters/ */ static unsigned int log_stats; @@ -404,7 +407,7 @@ static void purge_persistent_gnt(struct xen_blkif_ring *ring) !ring->blkif->vbd.overflow_max_grants)) { num_clean = 0; } else { - num_clean = (max_pgrants / 100) * LRU_PERCENT_CLEAN; + num_clean = (max_pgrants / 100) * lru_percent_clean; num_clean = ring->persistent_gnt_c - max_pgrants + num_clean; num_clean = min(ring->persistent_gnt_c, num_clean); pr_debug("Going to purge at least %u persistent grants\n",