From patchwork Thu Aug 5 19:02:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D05B1C4338F for ; Thu, 5 Aug 2021 19:04:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7E04260EEA for ; Thu, 5 Aug 2021 19:04:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7E04260EEA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 52CA06B0082; Thu, 5 Aug 2021 15:03:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 501BA6B0083; Thu, 5 Aug 2021 15:03:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 354918D0001; Thu, 5 Aug 2021 15:03:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0213.hostedemail.com [216.40.44.213]) by kanga.kvack.org (Postfix) with ESMTP id 13BB26B0082 for ; Thu, 5 Aug 2021 15:03:54 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C41898249980 for ; Thu, 5 Aug 2021 19:03:53 +0000 (UTC) X-FDA: 78441951546.35.4CE5779 Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by imf21.hostedemail.com (Postfix) with ESMTP id 774D5D013475 for ; Thu, 5 Aug 2021 19:03:53 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 23F145810B9; Thu, 5 Aug 2021 15:03:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 05 Aug 2021 15:03:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=from :to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; s=fm1; bh=bav9UkYGZvp/S Y4+sEgDfc5Rj+WNvVLnm5fMaKPJQdk=; b=AoYLNFC8R8d82d/WRFYvXz1pQUcLY ZRdB+YJbC1BZ2LsdT8uiKSRXrKQOVFtQeszFb7gfKMFVkoXcKPlIjnJi6m15HUBJ v27YQLZxVgSFkWugx1CKQmkSWO0dzqkNnmLbNwsrnKH1epPoJunr+Wl1yZjyiuxR K08mh6TSDgVYc7yo9bQJlmV+WCj09RPZkyMdgpYgJ7a8aHhtbNahW9+6ydqynB3t Yhhg2VHHAmI+XOyJ8kDCRX4LtHjmd/58YE1pzjFpi7aq2xQzdZ7972LCCMCyV0Do GO0T9OEz1KP3fneJ4L2HZNsRfmdwIETiQmt/pQ7nvxY6jvOXCm0B4k8cA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:reply-to:subject :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=bav9UkYGZvp/SY4+sEgDfc5Rj+WNvVLnm5fMaKPJQdk=; b=FPhvCv8S EUsyNoH9KkfmXugX8+QcCXRQR00+NKVzQNjb59jnObV52uBKmPjj3MLPkZRQZqTp PXeAmHquCG3u/dTBtgygKNhxTPP/iKhnl78Bq9taENJgahMr/ABc9FDaNRIzcefv 3bdObHO6RklONprTBrHerpD2Uq44qKeeYqFZfEZWeiYIpFitAvlFJxwCfMJstJyJ dTMtKv1Yw+FK7qmmGMeTe+yu6UqHXvixNyI/1HWpDrbI9shzGMq703Xi5FqWeBYT E0xbjKLb/yUFgM3/hnDwvGt4s86ZGrNcbOpDdOfQDLKnc5U8/Fs0xCCzha6Jye3F nXlMcTGsol4ULg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:51 -0400 (EDT) From: Zi Yan To: David Hildenbrand , linux-mm@kvack.org Cc: Matthew Wilcox , Vlastimil Babka , "Kirill A . Shutemov" , Mike Kravetz , Michal Hocko , John Hubbard , linux-kernel@vger.kernel.org, Zi Yan , "Michael S. Tsirkin" , Jason Wang , virtualization@lists.linux-foundation.org Subject: [RFC PATCH 09/15] virtio: virtio_mem: use PAGES_PER_SECTION instead of MAX_ORDER_NR_PAGES Date: Thu, 5 Aug 2021 15:02:47 -0400 Message-Id: <20210805190253.2795604-10-zi.yan@sent.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210805190253.2795604-1-zi.yan@sent.com> References: <20210805190253.2795604-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=AoYLNFC8; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=FPhvCv8S; spf=pass (imf21.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.229 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 774D5D013475 X-Stat-Signature: rm9ewwszwzakx5byjufxpw44fnusak35 X-HE-Tag: 1628190233-970532 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: Zi Yan It keeps the existing behavior when MAX_ORDER grows beyond a section size. Signed-off-by: Zi Yan Cc: David Hildenbrand Cc: "Michael S. Tsirkin" Cc: Jason Wang Cc: virtualization@lists.linux-foundation.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- drivers/virtio/virtio_mem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index 19036922f7ef..bab5a81fa796 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -1105,11 +1105,11 @@ static void virtio_mem_clear_fake_offline(unsigned long pfn, */ static void virtio_mem_fake_online(unsigned long pfn, unsigned long nr_pages) { - const unsigned long max_nr_pages = MAX_ORDER_NR_PAGES; + const unsigned long max_nr_pages = PAGES_PER_SECTION; unsigned long i; /* - * We are always called at least with MAX_ORDER_NR_PAGES + * We are always called at least with PAGES_PER_SECTION * granularity/alignment (e.g., the way subblocks work). All pages * inside such a block are alike. */ @@ -1125,7 +1125,7 @@ static void virtio_mem_fake_online(unsigned long pfn, unsigned long nr_pages) if (PageDirty(page)) { virtio_mem_clear_fake_offline(pfn + i, max_nr_pages, false); - generic_online_page(page, MAX_ORDER - 1); + generic_online_page(page, PAGES_PER_SECTION - 1); } else { virtio_mem_clear_fake_offline(pfn + i, max_nr_pages, true); @@ -1228,7 +1228,7 @@ static void virtio_mem_online_page_cb(struct page *page, unsigned int order) if (vm->in_sbm) { /* * We exploit here that subblocks have at least - * MAX_ORDER_NR_PAGES size/alignment - so we cannot + * PAGES_PER_SECTION size/alignment - so we cannot * cross subblocks within one call. */ id = virtio_mem_phys_to_mb_id(addr); @@ -2438,14 +2438,14 @@ static int virtio_mem_init(struct virtio_mem *vm) VIRTIO_MEM_DEFAULT_OFFLINE_THRESHOLD); /* - * We want subblocks to span at least MAX_ORDER_NR_PAGES and + * We want subblocks to span at least PAGES_PER_SECTION and * pageblock_nr_pages pages. This: * - Simplifies our page onlining code (virtio_mem_online_page_cb) * and fake page onlining code (virtio_mem_fake_online). * - Is required for now for alloc_contig_range() to work reliably - * it doesn't properly handle smaller granularity on ZONE_NORMAL. */ - sb_size = max_t(uint64_t, MAX_ORDER_NR_PAGES, + sb_size = max_t(uint64_t, PAGES_PER_SECTION, pageblock_nr_pages) * PAGE_SIZE; sb_size = max_t(uint64_t, vm->device_block_size, sb_size);