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=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 17D5EC43635 for ; Mon, 21 Sep 2020 17:43:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7A3D92193E for ; Mon, 21 Sep 2020 17:43:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C7h6inMm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A3D92193E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AC2DF90009D; Mon, 21 Sep 2020 13:43:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A98C490008B; Mon, 21 Sep 2020 13:43:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D58890009D; Mon, 21 Sep 2020 13:43:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0062.hostedemail.com [216.40.44.62]) by kanga.kvack.org (Postfix) with ESMTP id 876B290008B for ; Mon, 21 Sep 2020 13:43:01 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 498F5181AC9CB for ; Mon, 21 Sep 2020 17:43:01 +0000 (UTC) X-FDA: 77287789362.22.seed16_2404dff27147 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 2CC2A18038E60 for ; Mon, 21 Sep 2020 17:43:01 +0000 (UTC) X-HE-Tag: seed16_2404dff27147 X-Filterd-Recvd-Size: 5744 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Sep 2020 17:43:00 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id l71so9679593pge.4 for ; Mon, 21 Sep 2020 10:43:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=QtMGv9Az8n8/1NHjLi6o0NjvgH4+/FeF5Ci7mHb3HKk=; b=C7h6inMmXViVfdzLNOvFuTTw5gDP/PsNQbK7XEZloBeiZ8TI/21zMOjn7CNA+2JpdR fcqHDQGOwu00JGZ24OItIms+ocEi5vn4ArXzVIiiv3IsrWX58V+/xvf5GAM6uWt45WHV J5uOcJSwwSsyQG3DI06e7LXhdO9u9oPEpVS+RmLizgAmeHXs0yGsQU1nOXkBOVIfgxKA R2QFqMXS/jWK8IGcmqN0UiZJVAO1wKzNqskrF4+I7n3VyZXcnkek4EZphD0W4XzFqzOv ok0cZ2Pc39gKnqlEn4+P3Rhkp0HO3HdeqOVIlHDzJsQPR318T1EvvNwcSWIeqku82piy vqZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=QtMGv9Az8n8/1NHjLi6o0NjvgH4+/FeF5Ci7mHb3HKk=; b=NQOpTIWd1QcZcIrI0G2XfVbehltrM8lp552UzJYjdS2bi9De/gS+RNHyj6rZRbI37P 6ORNZL/JLxF9o9vtqhjd3dFRj2gFsOX8sey2eccJ2kWj0p3aTog7Qd7KVTW6GnKdrEXt AkIqOM9+wHhZ2ihGojOuDhD4d9DyBkj2nH/j9rc6mSwlZCFBWhAk8pn7sMD/QczhbJhf WjCYv/6DUTM6mO2jWyrx3qMZkD1tT98Ve1dW68bqrAfi8siBtOLC4AzUyrKkuXYysbm6 jGrZWs3t4CQfw9zwe+tCPfTOMT0r7qjEvKdQmA3SaY9MXIWNc1BurpjlvgKa5mCuMK9T 3oxg== X-Gm-Message-State: AOAM531FQVqa3pmcz+Ewy6CZUUV3U/mu/JGWjMNImKzFH2UoaaY+ozdz 6xmLJdNYy+z064H3/iUqMas= X-Google-Smtp-Source: ABdhPJz3bQvQ0y+Tkl35pFZsVWVp7/jEG6xMj1AV8L7OC4sV/ELLhXdmGbDdT9tBGrtDXWjgu18MoQ== X-Received: by 2002:a17:902:8695:b029:d2:29b:991a with SMTP id g21-20020a1709028695b02900d2029b991amr1034190plo.80.1600710179810; Mon, 21 Sep 2020 10:42:59 -0700 (PDT) Received: from google.com ([2620:15c:211:1:7220:84ff:fe09:5e58]) by smtp.gmail.com with ESMTPSA id ca6sm123394pjb.53.2020.09.21.10.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 10:42:58 -0700 (PDT) Date: Mon, 21 Sep 2020 10:42:56 -0700 From: Minchan Kim To: Christoph Hellwig Cc: Andrew Morton , Peter Zijlstra , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Nitin Gupta , x86@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org Subject: Re: [PATCH 1/6] zsmalloc: switch from alloc_vm_area to get_vm_area Message-ID: <20200921174256.GA387368@google.com> References: <20200918163724.2511-1-hch@lst.de> <20200918163724.2511-2-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200918163724.2511-2-hch@lst.de> 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: On Fri, Sep 18, 2020 at 06:37:19PM +0200, Christoph Hellwig wrote: > There is no obvious reason why zsmalloc needs to pre-fault the PTEs > given that it later uses map_kernel_range to just like vmap(). IIRC, the problem was runtime pte popluating needs GFP_KERNEL but zs_map_object API runs under non-preemtible section. > > Signed-off-by: Christoph Hellwig > --- > mm/zsmalloc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c > index c36fdff9a37131..3e4fe3259612fd 100644 > --- a/mm/zsmalloc.c > +++ b/mm/zsmalloc.c > @@ -1122,7 +1122,7 @@ static inline int __zs_cpu_up(struct mapping_area *area) > */ > if (area->vm) > return 0; > - area->vm = alloc_vm_area(PAGE_SIZE * 2, NULL); > + area->vm = get_vm_area(PAGE_SIZE * 2, 0); > if (!area->vm) > return -ENOMEM; > return 0; I think it shoud work. diff --git a/mm/memory.c b/mm/memory.c index 05789aa4af12..6a1e4d854593 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2232,7 +2232,7 @@ static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd, arch_enter_lazy_mmu_mode(); do { - if (create || !pte_none(*pte)) { + if ((create || !pte_none(*pte)) && fn) { err = fn(pte++, addr, data); if (err) break; diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 3e4fe3259612..9ef7daf3d279 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1116,6 +1116,8 @@ static struct zspage *find_get_zspage(struct size_class *class) #ifdef CONFIG_ZSMALLOC_PGTABLE_MAPPING static inline int __zs_cpu_up(struct mapping_area *area) { + int ret; + /* * Make sure we don't leak memory if a cpu UP notification * and zs_init() race and both call zs_cpu_up() on the same cpu @@ -1125,7 +1127,13 @@ static inline int __zs_cpu_up(struct mapping_area *area) area->vm = get_vm_area(PAGE_SIZE * 2, 0); if (!area->vm) return -ENOMEM; - return 0; + + /* + * Populate ptes in advance to avoid pte allocation with GFP_KERNEL + * in non-preemtible context of zs_map_object. + */ + ret = apply_to_page_range(&init_mm, NULL, PAGE_SIZE * 2, NULL, NULL); + return ret; } static inline void __zs_cpu_down(struct mapping_area *area)