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=unavailable 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 A3450C4361C for ; Mon, 21 Sep 2020 17:43:02 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4C4EE2086A 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 4C4EE2086A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B3C616E061; Mon, 21 Sep 2020 17:43:01 +0000 (UTC) Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F4F86E061; Mon, 21 Sep 2020 17:43:00 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id n14so9898777pff.6; 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=NWLqyMgIZLgyq4eMOuV7j5dbGQ59qbpHx41vOx+OchlJzgAFTCtJU284/Ct7dPhayV Xr9P5A2HpmfGboypAunaX1ltSyZAAnYLLd8Ctay1muLMRJD3kBbV/DNU7Xg9dEmFNvlH nT8kbtJWqUSQc7fxb1QYmr0M+HLKL+CVnvVPaV4vDj3RYshiXPvUBRUYZtHOMMmA6d40 UhfCeLv0beEsZRoU/1zkKd/4mgdLTGslZol/pPQSW1o4bOaUSIb5sunD3eBFTnMed4sB y7TvJXszaPxPuf6fOY6+dSw/TkHdL9toLa9oNSD6vQ4r7hcj3eAPlLF9M7vgS2lHh0xI SR8w== X-Gm-Message-State: AOAM532xl13neHjndb6DNJPtwpcK8NmEGN0lWjzhOTPu7rkrKRRhPv5V SL4fpejoQKYabRS2gm6rOBo= 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 Message-ID: <20200921174256.GA387368@google.com> References: <20200918163724.2511-1-hch@lst.de> <20200918163724.2511-2-hch@lst.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200918163724.2511-2-hch@lst.de> Subject: Re: [Intel-gfx] [PATCH 1/6] zsmalloc: switch from alloc_vm_area to get_vm_area X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Peter Zijlstra , intel-gfx@lists.freedesktop.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, Andrew Morton , Boris Ostrovsky , Nitin Gupta Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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) _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx