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: 11839427 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 2F74061C for ; Thu, 15 Oct 2020 14:26:30 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2D7122255 for ; Thu, 15 Oct 2020 14:26:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="gnxBu0Ok" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2D7122255 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.7415.19370 (Exim 4.92) (envelope-from ) id 1kT4CO-0004bX-ST; Thu, 15 Oct 2020 14:25:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 7415.19370; Thu, 15 Oct 2020 14:25:44 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kT4CO-0004bP-P8; Thu, 15 Oct 2020 14:25:44 +0000 Received: by outflank-mailman (input) for mailman id 7415; Thu, 15 Oct 2020 14:25:43 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kT4CN-0004ay-GJ for xen-devel@lists.xenproject.org; Thu, 15 Oct 2020 14:25:43 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ef1122d1-2b9c-4702-bf1d-9b0e24451e7e; Thu, 15 Oct 2020 14:25:42 +0000 (UTC) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kT4CN-0004ay-GJ for xen-devel@lists.xenproject.org; Thu, 15 Oct 2020 14:25:43 +0000 X-Inumbo-ID: ef1122d1-2b9c-4702-bf1d-9b0e24451e7e Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ef1122d1-2b9c-4702-bf1d-9b0e24451e7e; Thu, 15 Oct 2020 14:25:42 +0000 (UTC) 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 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",