From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,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 E6047C433FE for ; Mon, 7 Dec 2020 11:34:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7E0B123340 for ; Mon, 7 Dec 2020 11:34:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E0B123340 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 147F08D000D; Mon, 7 Dec 2020 06:34:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 11E718D0001; Mon, 7 Dec 2020 06:34:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00BFC8D000D; Mon, 7 Dec 2020 06:34:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0138.hostedemail.com [216.40.44.138]) by kanga.kvack.org (Postfix) with ESMTP id DF93A8D0001 for ; Mon, 7 Dec 2020 06:34:05 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9FC031EE6 for ; Mon, 7 Dec 2020 11:34:05 +0000 (UTC) X-FDA: 77566277250.13.room48_5106398273de Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 7CBBF18140B60 for ; Mon, 7 Dec 2020 11:34:05 +0000 (UTC) X-HE-Tag: room48_5106398273de X-Filterd-Recvd-Size: 5890 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Mon, 7 Dec 2020 11:34:04 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id i3so6026827pfd.6 for ; Mon, 07 Dec 2020 03:34:04 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=qTNI65Ra3SvOxRqRKBzegtUpucaZ64C3XLV6YdV+FWI=; b=WZ7Du0ULB95oU81wnLc5gl3z/aytDZ/R8hi+jxeHPvL3Uj6qbl1w6qJYy8PYblreD7 KkS3EAfoEHij1nALKdPH1U4pxPS0IyvqqemIQiGQMyDBC7uDpffb/MAkinfFKdVcbzW+ ccqmpEumCFtRql9bw4TNMZX2lqp8gs6naZPHyGLUqJUJGO5hakqfFrv5eThcK9prsbyq rA5jkLCAuckYLJvmJ/7JoZy+hde7C1WAvWqFV42rW7dKwCVNU9p/OVP/OE9bqgO1xMQS M+Ap2sPI4y9/jiLNfsu4126AgBFlUfyiLrevHYALZF4wOYdHEUv5qkHHoVqj09LrY8u0 OGAg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=qTNI65Ra3SvOxRqRKBzegtUpucaZ64C3XLV6YdV+FWI=; b=avvrMANJXpUjQa5P9ERidAuT/Pp6ltVy+JtuBTQ9FBrYH8SinD3wEz7Kvdd8LSY7oc eTjCi9Zs04NL1OZWMQ67gXYcVEQP+NsUczjmgmyNpa4qh/HS//fkvt7PwlvVxZUjoOX6 P3aNPMaMEMcbnIMjqKxSicAb+oRRgfbfkI/usIL4uDU7A/ar1camyDpFBHexhFCfx9/Z KOonxQwF2Lh0LhdWP28F9gXu6gywqk9PS6ChkM/vw1Q43pEAktD512zOH4jnncnfIoKM ozfSfMYP/vEhvBN3h91ytEGDcHTAVQzDOFbvXGfCZ0uKOjYoYnikrFBrzqaTOfbXEtGf WNMA== X-Gm-Message-State: AOAM5307rpBx+QySBMPhQtgcTCxPHp3dtOJypqJQL1xF3cujGJvpGWKC MBMrNi8QaqDHbhn9aWOwVGAptzCE7Kc= X-Google-Smtp-Source: ABdhPJzLlbx7N/WW+brtTZmzWtaMEPGG1TMIRCFOt3UUqUvhW972s9iQVTyzpcnADKQPTclv8/zM4g== X-Received: by 2002:a62:5205:0:b029:19e:a0f:2c81 with SMTP id g5-20020a6252050000b029019e0a0f2c81mr4652442pfb.50.1607340844089; Mon, 07 Dec 2020 03:34:04 -0800 (PST) Received: from localhost.localdomain ([203.205.141.39]) by smtp.gmail.com with ESMTPSA id d4sm14219822pfo.127.2020.12.07.03.34.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Dec 2020 03:34:03 -0800 (PST) From: yulei.kernel@gmail.com X-Google-Original-From: yuleixzhang@tencent.com To: linux-mm@kvack.org, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, naoya.horiguchi@nec.com, viro@zeniv.linux.org.uk, pbonzini@redhat.com Cc: joao.m.martins@oracle.com, rdunlap@infradead.org, sean.j.christopherson@intel.com, xiaoguangrong.eric@gmail.com, kernellwp@gmail.com, lihaiwei.kernel@gmail.com, Yulei Zhang , Xiao Guangrong Subject: [RFC V2 10/37] dmemfs: introduce max_alloc_try_dpages parameter Date: Mon, 7 Dec 2020 19:31:03 +0800 Message-Id: <08ff7e40806a2342720835b95f9be24d5778c703.1607332046.git.yuleixzhang@tencent.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: Yulei Zhang It specifies the dmem page number allocated at one time, then multiple radix entries can be created. That will relief the allocation pressure and make page fault more fast. However that could cause no dmem page mmapped to userspace even if there are some free dmem pages. Set it to 1 to completely disable this behavior. Signed-off-by: Xiao Guangrong Signed-off-by: Yulei Zhang --- fs/dmemfs/inode.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/fs/dmemfs/inode.c b/fs/dmemfs/inode.c index 3192f31..443f2e1 100644 --- a/fs/dmemfs/inode.c +++ b/fs/dmemfs/inode.c @@ -34,6 +34,8 @@ #define CREATE_TRACE_POINTS #include "trace.h" =20 +static uint __read_mostly max_alloc_try_dpages =3D 1; + struct dmemfs_mount_opts { unsigned long dpage_size; }; @@ -46,6 +48,44 @@ enum dmemfs_param { Opt_dpagesize, }; =20 +static int +max_alloc_try_dpages_set(const char *val, const struct kernel_param *kp) +{ + uint sval; + int ret; + + ret =3D kstrtouint(val, 0, &sval); + if (ret) + return ret; + + /* should be 1 at least */ + if (!sval) + return -EINVAL; + + max_alloc_try_dpages =3D sval; + return 0; +} + +static struct kernel_param_ops alloc_max_try_dpages_ops =3D { + .set =3D max_alloc_try_dpages_set, + .get =3D param_get_uint, +}; + +/* + * it specifies the dmem page number allocated at one time, then + * multiple radix entries can be created. That will relief the + * allocation pressure and make page fault more fast. + * + * however that could cause no dmem page mmapped to userspace + * even if there are some free dmem pages + * + * set it to 1 to completely disable this behavior + */ +fs_param_cb(max_alloc_try_dpages, &alloc_max_try_dpages_ops, + &max_alloc_try_dpages, 0644); +__MODULE_PARM_TYPE(max_alloc_try_dpages, "uint"); +MODULE_PARM_DESC(max_alloc_try_dpages, "Set the dmem page number allocat= ed at one time, should be 1 at least"); + const struct fs_parameter_spec dmemfs_fs_parameters[] =3D { fsparam_string("pagesize", Opt_dpagesize), {} @@ -314,6 +354,7 @@ static void *find_radix_entry_or_next(struct address_= space *mapping, } rcu_read_unlock(); =20 + try_dpages =3D min(try_dpages, max_alloc_try_dpages); /* entry does not exist, create it */ addr =3D dmem_alloc_pages_vma(vma, fault_addr, try_dpages, &dpages); if (!addr) { --=20 1.8.3.1