Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp155278ybl; Tue, 10 Dec 2019 19:51:58 -0800 (PST) X-Google-Smtp-Source: APXvYqyPHG7qSpMqS2XU0XZSLZx0umfNeKK19yN9czfFdZR/0hJgc1sA7TCzuzNyR1cOR56Gv7A/ X-Received: by 2002:a05:6830:139a:: with SMTP id d26mr871887otq.75.1576036318829; Tue, 10 Dec 2019 19:51:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576036318; cv=none; d=google.com; s=arc-20160816; b=TCHGWQ0emyIboiNMMNtfb7D0XKy0z8ax4v7zXe8cJ4cM9YPVH5UMC226w1fHVBEe7/ /houkMdxsYc8Kd7zc3gOtzVBA4apkIU8FCgA89VLQ1dS7g5F+GeIKhLfoMAqZV+M++tM mlR+SFTBRTLQGf5a4ovRYzPAjcG3Ntp3rhxl92qJKbePUT7hnl5ChLmeoBeiFchQkN5t amdbGYYKH2ngJ5piYQj3t1AvhozWrFn7VZ8WRU21nsevOYjVv4TYitbAp9ZEzRUBTBh5 U4kiTMpOO1SXyW7+e27okLkTqvAelHTr67N6xhbZSDqL07g9AxAaKWY0DM2HRAqoGRhL foxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=w9o4gMDR79zJbq+/ILGvB1xN+aaga7BtIGFfI8prB5M=; b=gOx3DuensOxVzeIBdowUh12e/FXxHf9dBWj4moYQCBUQn+n9sGW31YYEJAikcIgsu2 uqclu0wPf3jIRGBSuaHru0lNBoo1EpA7dAZOiuOyR6CkAu9P+dlUqI5xIPJ5yMAUEL8Q XXobZM7jIowyE2d/OA4p5ZGIPjdp4S7FSJaApbMrS7Z2QQibaQtI3WMY/16XdIzx+Z7s AbGH1FcaVLe8uiZMA9x52f17AjqHV3OOWQgk85CQs2TEeDtUa9WcWI5Jo9CHnpt448x0 eRjpul71ZOFkKxIXDnjpWcNhof2lnvbZ17qQe27igRd6KgFoP5U3VPEuShs03QxUQGng t5cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cb2c4Qu1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i185si407899oia.187.2019.12.10.19.51.46; Tue, 10 Dec 2019 19:51:58 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cb2c4Qu1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726989AbfLKDvO (ORCPT + 99 others); Tue, 10 Dec 2019 22:51:14 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:36336 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbfLKDvN (ORCPT ); Tue, 10 Dec 2019 22:51:13 -0500 Received: by mail-pj1-f65.google.com with SMTP id n96so8366654pjc.3; Tue, 10 Dec 2019 19:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version:in-reply-to :content-transfer-encoding; bh=w9o4gMDR79zJbq+/ILGvB1xN+aaga7BtIGFfI8prB5M=; b=cb2c4Qu1c1VKdo14t+tdEIreffodBdWgrfZOnau+8AaTsPYBHxEDq2ozEzFFz/pEXz 1Pz5xgaVxS7aheHrbjvMvC0DfUNyVafnjbnzBHpv7NUksimAVRA4gVCZVj8Ydn64MoVb CSt+5FDPXEO6+HIN1gVgL2lUTUC0OSJJD+IC0nahZy4jbR2rtY9d53t++mdn3OYc1Jj9 PAQUqBaUzQA1lWISbOFvz5im/enk1rQV5SA86x8ZF0GMnO3BK7HOp+osbtQhfGOBFXHm gKXy/czYdBvRWV7jv/jpcYv/8/AfbBfxTfHGyhIYxJrKgDDf18qfGpkIS34S2xVClL79 X7dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :in-reply-to:content-transfer-encoding; bh=w9o4gMDR79zJbq+/ILGvB1xN+aaga7BtIGFfI8prB5M=; b=Fa9/NQ616nFX+TBgw/Sf8v1bTWPQ4DWe/H4DVPrnlCWW7n7gCOTvsdCv6U/5ChU3/W nAQl3KE/faPj9UP92wstvUdsxheKDQqsbs2BmlTBNoqrrmk4JOu8hFnX2iILWrrgbdXq K0wBT+e5NuV8N+fDf1k+1glmKKWZeN6wYXo5mtLfkObHHmrxd6mj3lYWwnbuPWUu1B0u 8zlUlqc/DA/8lWgFt3GDdqmcqXLHGhn0Tj59NkXhpxijBIKI4xtl5G4jvwQH/zQ6uk4l Ga9QOz0jegBt9DQMVuhrI83L97cPiQUL0ID4emRTCoANrKW7NmzNPLkTE5DWoRJS0cJf KvKw== X-Gm-Message-State: APjAAAWawWc4hUaUwA/nhTy27IfGx05Go60ACqxK+oj9AktRTFydz83m opy+Ddga/zYJ53//3NPVABI= X-Received: by 2002:a17:902:6909:: with SMTP id j9mr1012338plk.136.1576036272826; Tue, 10 Dec 2019 19:51:12 -0800 (PST) Received: from localhost.localdomain ([12.176.148.120]) by smtp.gmail.com with ESMTPSA id u3sm501061pga.72.2019.12.10.19.51.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Dec 2019 19:51:11 -0800 (PST) From: SeongJae Park To: roger.pau@citrix.com Cc: sjpark@amazon.com, axboe@kernel.dk, konrad.wilk@oracle.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, pdurrant@amazon.com, xen-devel@lists.xenproject.org, SeongJae Park , sj38.park@gmail.com Subject: Re: Re: [PATCH v5 1/2] xenbus/backend: Add memory pressure handler callback Date: Wed, 11 Dec 2019 04:50:58 +0100 Message-Id: <20191211035058.11479-1-sj38.park@gmail.com> X-Mailer: git-send-email 2.17.2 MIME-Version: 1.0 In-Reply-To: <20191210101635.GD980@Air-de-Roger> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 10 Dec 2019 11:16:35 +0100 "Roger Pau Monné" wrote: > > Granting pages consumes backend system memory. In systems configured > > with insufficient spare memory for those pages, it can cause a memory > > pressure situation. However, finding the optimal amount of the spare > > memory is challenging for large systems having dynamic resource > > utilization patterns. Also, such a static configuration might lack a > > s/lack a/lack/ > > > flexibility. > > > > To mitigate such problems, this commit adds a memory reclaim callback to > > 'xenbus_driver'. Using this facility, 'xenbus' would be able to monitor > > a memory pressure and request specific devices of specific backend > > s/monitor a/monitor/ > > > drivers which causing the given pressure to voluntarily release its > > ...which are causing... > > > memory. > > > > That said, this commit simply requests every callback registered driver > > to release its memory for every domain, rather than issueing the > > s/issueing/issuing/ > > > requests to the drivers and the domain in charge. Such things will be > > I'm afraid I don't understand the "domain in charge" part of this > sentence. > > > done in a futur. Also, this commit focuses on memory only. However, it > > ... done in a future change. Also I think the period after only should > be removed in order to tie both sentences together. > > > would be ablt to be extended for general resources. > > s/ablt/able/ > > > > > Signed-off-by: SeongJae Park > > --- > > drivers/xen/xenbus/xenbus_probe_backend.c | 31 +++++++++++++++++++++++ > > include/xen/xenbus.h | 1 + > > 2 files changed, 32 insertions(+) > > > > diff --git a/drivers/xen/xenbus/xenbus_probe_backend.c b/drivers/xen/xenbus/xenbus_probe_backend.c > > index b0bed4faf44c..5a5ba29e39df 100644 > > --- a/drivers/xen/xenbus/xenbus_probe_backend.c > > +++ b/drivers/xen/xenbus/xenbus_probe_backend.c > > @@ -248,6 +248,34 @@ static int backend_probe_and_watch(struct notifier_block *notifier, > > return NOTIFY_DONE; > > } > > > > +static int xenbus_backend_reclaim(struct device *dev, void *data) > > +{ > > + struct xenbus_driver *drv; > > Newline and const. > > > + if (!dev->driver) > > + return -ENOENT; > > + drv = to_xenbus_driver(dev->driver); > > + if (drv && drv->reclaim) > > + drv->reclaim(to_xenbus_device(dev)); > > You seem to completely ignore the return of the reclaim hook... > > > + return 0; > > +} > > + > > +/* > > + * Returns 0 always because we are using shrinker to only detect memory > > + * pressure. > > + */ > > +static unsigned long xenbus_backend_shrink_count(struct shrinker *shrinker, > > + struct shrink_control *sc) > > +{ > > + bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, > > + xenbus_backend_reclaim); > > + return 0; > > +} > > + > > +static struct shrinker xenbus_backend_shrinker = { > > + .count_objects = xenbus_backend_shrink_count, > > + .seeks = DEFAULT_SEEKS, > > +}; > > + > > static int __init xenbus_probe_backend_init(void) > > { > > static struct notifier_block xenstore_notifier = { > > @@ -264,6 +292,9 @@ static int __init xenbus_probe_backend_init(void) > > > > register_xenstore_notifier(&xenstore_notifier); > > > > + if (register_shrinker(&xenbus_backend_shrinker)) > > + pr_warn("shrinker registration failed\n"); > > + > > return 0; > > } > > subsys_initcall(xenbus_probe_backend_init); > > diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h > > index 869c816d5f8c..cdb075e4182f 100644 > > --- a/include/xen/xenbus.h > > +++ b/include/xen/xenbus.h > > @@ -104,6 +104,7 @@ struct xenbus_driver { > > struct device_driver driver; > > int (*read_otherend_details)(struct xenbus_device *dev); > > int (*is_ready)(struct xenbus_device *dev); > > + unsigned (*reclaim)(struct xenbus_device *dev); > > ... hence I wonder why it's returning an unsigned when it's just > ignored. > > IMO it should return an int to signal errors, and the return should be > ignored. I first thought similarly and set the callback to return something. However, as this callback is called to simply notify the memory pressure and ask the driver to free its memory as many as possible, I couldn't easily imagine what kind of errors that need to be handled by its caller can occur in the callback, especially because current blkback's callback implementation has no such error. So, if you and others agree, I would like to simply set the return type to 'void' for now and defer the error handling to a future change. > > Also, I think it would preferable for this function to take an extra > parameter to describe the resource the driver should attempt to free > (ie: memory or interrupts for example). I'm however not able to find > any existing Linux type to describe such resources. Yes, such extention would be the right direction. However, because there is no existing Linux type to describe the type of resources to reclaim as you also mentioned, there could be many different opinions about its implementation detail. In my opinion, it could be also possible to simply add another callback for another resource type. That said, because currently we have an use case and an implementation for the memory pressure only, I would like to let it as is for now and defer the extension as a future work, if you and others have no objection. Thanks, SeongJae Park > > Thanks, Roger. > >