From patchwork Tue Nov 19 21:46:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11252717 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 394141390 for ; Tue, 19 Nov 2019 21:46:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E3D7422460 for ; Tue, 19 Nov 2019 21:46:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bLCsx9ru" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3D7422460 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 21B856B000A; Tue, 19 Nov 2019 16:46:44 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1CC7F6B000C; Tue, 19 Nov 2019 16:46:44 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06EBD6B000D; Tue, 19 Nov 2019 16:46:44 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E63EC6B000A for ; Tue, 19 Nov 2019 16:46:43 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id A0C698249980 for ; Tue, 19 Nov 2019 21:46:43 +0000 (UTC) X-FDA: 76174361886.21.mom32_74246b2b009 X-Spam-Summary: 2,0,0,c5e3a1af7198cbd7,d41d8cd98f00b204,alexander.duyck@gmail.com,:kvm@vger.kernel.org:mst@redhat.com:linux-kernel@vger.kernel.org:willy@infradead.org:mhocko@kernel.org::akpm@linux-foundation.org:mgorman@techsingularity.net:vbabka@suse.cz:yang.zhang.wz@gmail.com:nitesh@redhat.com:konrad.wilk@oracle.com:david@redhat.com:pagupta@redhat.com:riel@surriel.com:lcapitulino@redhat.com:dave.hansen@intel.com:wei.w.wang@intel.com:aarcange@redhat.com:pbonzini@redhat.com:dan.j.williams@intel.com:alexander.h.duyck@linux.intel.com:osalvador@suse.de,RULES_HIT:41:152:355:379:960:966:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1535:1543:1593:1594:1711:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2553:2559:2562:2693:3138:3139:3140:3141:3142:3355:3743:3865:3866:3867:3868:3870:3871:3872:3874:4117:4250:4321:4385:5007:6119:6261:6653:6742:7576:7903:7974:8660:9108:9413:10004:10400:11026:11232:11473:11658:11914:12043:12048:12291:12297:12438:125 17:12519 X-HE-Tag: mom32_74246b2b009 X-Filterd-Recvd-Size: 6609 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Tue, 19 Nov 2019 21:46:43 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id s10so12643454plp.2 for ; Tue, 19 Nov 2019 13:46:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=OKKmBSH+nYC1HLRQ37JbMq2XbZg5f7HxUos9scjzwrQ=; b=bLCsx9ru+UHMSt3gT7qB1CWyChHpU/Cgn+wFTpIOECPUtIfEDwBQBpLLy89GQsCClz SBYh1m0XdZw8S1Dcm36AkeOoc1gxJNi58y5H1tVceEEWIfLN0cgNQqArX8ilJW7KFwhW uc+zVxWtG1glg2wZIRpqAoYEBUY3FPyvjenxxMLGO4f9TAxnn76xnHRifyRBEgbVhlh0 qLahJCba5+mZKNsXlqq9ZM9fEi/tGV5GpZ2APSmvMq9CYmjEtrCbLwKXEfgOjw4+ZoYW tJm6ByBN5T29T5nbKJ1bkFaAZ4g5wog/qDo0ErIyPWS8Nzh0/TkhrCAgthMNv69692DL Q3UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=OKKmBSH+nYC1HLRQ37JbMq2XbZg5f7HxUos9scjzwrQ=; b=Fy6qv/TZQWOYfPl2rAjBqps5d8ijIjfVrjnWsTkfYEPZhqXNn3ZpsvwrYt/nC1b+0J h9bYREnp5fVBrotLGuq7rQtO8SpdMSxBDKERPhTBCzktFsP8vkxoE7Wpa3aOyxERqoSJ fufu9HdBc1gC7oX6AX4cz1JBBD7+7ziMBt0Ucqn2HRjQWrNbB2JJxb369e6ZRaNJXg/q D+9wtS0hTRNqYgDSQCrYQ48A1cCsM9M4465EQcTXGp2tPpcpKWgcFWChspk6X9na9VsH DOPPqzI+eqanudSq1k6SjDJa+GlGhQmaI2ZW4+he/BcTlcfh4W0s06vD6gajMCAaZV7y YzsA== X-Gm-Message-State: APjAAAXZ/sJ+qeZaYuR+MJ+rVoKZvPMuq2hW9oyleF2CDHpBMnJnT7Ud kMPM5Ab1DD+eDkg0LjbGX5w= X-Google-Smtp-Source: APXvYqxeW1MEo/1O/0PUJp9mcExSGRfdqDR/RyLReGkdJZNxm77Psbe49esAoHV54PX8xcfVO8jcQA== X-Received: by 2002:a17:90a:cc07:: with SMTP id b7mr9098948pju.135.1574200001821; Tue, 19 Nov 2019 13:46:41 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id x192sm29563012pfd.96.2019.11.19.13.46.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Nov 2019 13:46:41 -0800 (PST) Subject: [PATCH v14 4/6] mm: Add unused page reporting documentation From: Alexander Duyck To: kvm@vger.kernel.org, mst@redhat.com, linux-kernel@vger.kernel.org, willy@infradead.org, mhocko@kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net, vbabka@suse.cz Cc: yang.zhang.wz@gmail.com, nitesh@redhat.com, konrad.wilk@oracle.com, david@redhat.com, pagupta@redhat.com, riel@surriel.com, lcapitulino@redhat.com, dave.hansen@intel.com, wei.w.wang@intel.com, aarcange@redhat.com, pbonzini@redhat.com, dan.j.williams@intel.com, alexander.h.duyck@linux.intel.com, osalvador@suse.de Date: Tue, 19 Nov 2019 13:46:40 -0800 Message-ID: <20191119214640.24996.34494.stgit@localhost.localdomain> In-Reply-To: <20191119214454.24996.66289.stgit@localhost.localdomain> References: <20191119214454.24996.66289.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Alexander Duyck Add documentation for unused page reporting. Currently the only consumer is virtio-balloon, however it is possible that other drivers might make use of this so it is best to add a bit of documetation explaining at a high level how to use the API. Signed-off-by: Alexander Duyck --- Documentation/vm/unused_page_reporting.rst | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Documentation/vm/unused_page_reporting.rst diff --git a/Documentation/vm/unused_page_reporting.rst b/Documentation/vm/unused_page_reporting.rst new file mode 100644 index 000000000000..932406f48842 --- /dev/null +++ b/Documentation/vm/unused_page_reporting.rst @@ -0,0 +1,44 @@ +.. _unused_page_reporting: + +===================== +Unused Page Reporting +===================== + +Unused page reporting is an API by which a device can register to receive +lists of pages that are currently unused by the system. This is useful in +the case of virtualization where a guest is then able to use this data to +notify the hypervisor that it is no longer using certain pages in memory. + +For the driver, typically a balloon driver, to use of this functionality +it will allocate and initialize a page_reporting_dev_info structure. The +fields within the structure it will populate are the "report" function +pointer used to process the scatterlist and "capacity" representing the +number of entries that the device can support in a single request. Once +those are populated a call to page_reporting_register will allocate the +scatterlist and register the device with the reporting framework assuming +no other page reporting devices are already registered. + +Once registered the page reporting API will begin reporting batches of +pages to the driver. The API determines that it needs to start reporting by +measuring the number of pages in a given free area versus the number of +reported pages for that free area. If the value meets or exceeds the value +defined by PAGE_REPORTING_HWM then the zone is flagged as requesting +reporting and a worker is scheduled to process zone requesting reporting. + +Pages reported will be stored in the scatterlist pointed to in the +page_reporting_dev_info with the final entry having the end bit set in +entry nent - 1. While pages are being processed by the report function they +will not be accessible to the allocator. Once the report function has been +completed the pages will be returned to the free area from which they were +obtained. + +Prior to removing a driver that is making use of unused page reporting it +is necessary to call page_reporting_unregister to have the +page_reporting_dev_info structure that is currently in use by unused page +reporting removed. Doing this will prevent further reports from being +issued via the interface. If another driver or the same driver is +registered it is possible for it to resume where the previous driver had +left off in terms of reporting unused pages. + +Alexander Duyck, Nov 15, 2019 +