Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3871092rdh; Tue, 28 Nov 2023 06:10:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IH2eyOcl6wcl5NurnXxhFep2/vGDITeGdeCakh/YPou1kr6bAWaOi64LM+Ol9+ov0h+VXnY X-Received: by 2002:a05:6808:14cf:b0:3b8:5c79:93d5 with SMTP id f15-20020a05680814cf00b003b85c7993d5mr14719098oiw.11.1701180653683; Tue, 28 Nov 2023 06:10:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701180653; cv=none; d=google.com; s=arc-20160816; b=iioD1f67kDiHQH1o6YB49XKbbH8dk61lUbsVx8xQnVwBra8LRQpKi7S2Wmr0V6Gzhg kbtkIdWcGhZa6cXhjURypfWl2OJPqR4w16hNmkclsbGTEfrMbo6gQ/lSBnd8atzEejrT pZYSC/pKDHW2F8e/lC7R01bqsu/fuEL/cucFW7Y36V5iCDYbePA41hWHr7+Zkqwc5zT8 t2//MXjifurvhxOiMwycimsx8APp32/PRtM7QG5PL+c8upQ2d8cP93lcLEfwMefE+wP8 ZoyMV8asidx7ygZRUZhjKtknCHtTzBT3ABZ+JUzMrcwQnHBxOxdbqvTbb5L025FAo25s hKaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=A7y0NaJ5ptNfygrxlKgEvacGOGqd4/7FIdJrvhOt2fQ=; fh=Z3jMDIkydY0N+0LtOROXBJKMI3GazgwgQkSJrdPVX2Q=; b=QFPEqofW++B5zyC2PYCoSbKv/3aSdS6FHRjzWPQ7R29HAi9w7xfJ+Ik3XVfR41hvCg leKi7VRxTi/lILOnrnu21VjTMqCpFxxSnxY6V8vBaHARDf/Fl9emGA4bxlm14uRMJA9J r20AotZZn15hlAYQ4kBWlMJPVAkQLDwIQjTV9gjjS6VepWvpq2yCOHb7Mj5SMtCP0ZJD eqT2k+txFH2TMoCqukjOh2y5gt+OC07S45Pm8g/wzckq6iuLESNH5UuTtt81yPwWhQml Q2VxmigZmzHkKA2io85n3THIh7Apmfcy0i2aDUhQN19kLfDlQBzySM1B5JvYgQM2QrdS BMQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=uUVvi2np; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id fg14-20020a056808640e00b003b834603fb4si5108767oib.313.2023.11.28.06.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 06:10:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=uUVvi2np; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 0892E801B18F; Tue, 28 Nov 2023 06:10:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346201AbjK1OK0 (ORCPT + 99 others); Tue, 28 Nov 2023 09:10:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345591AbjK1OKB (ORCPT ); Tue, 28 Nov 2023 09:10:01 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E738E2D47 for ; Tue, 28 Nov 2023 06:09:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=A7y0NaJ5ptNfygrxlKgEvacGOGqd4/7FIdJrvhOt2fQ=; b=uUVvi2npCvBXaVE6gIxQKBfIQv CTE+dhpfxOetIJE/TyjYvkaa02UjWwAMADAt6T2Ql/5IM2pVvPgkMzQDaNhUOXRIQnWEJ3KZU4IR1 UlswKcp3yz+7Gx/z9sUTpUis/wl7HWwlhF2hbZs6KqIa/wn2hXngJNfxtBAOfgrt6a1WFka1UfPtB Uj+jvalgspDkRSf8OfGuFYGdS/Ni/y2F5Q8bJ6zkGY73N8lWnnKbPVDwY1Obu3NgtFM9Nv3Vx2HFk DhNgixO40A5MK3IkrL2eHOD4moFyH4mWH0osEBYHBPYEOSbj84SRv0+Z4rvHd9eHTF2e7J4pckxUw ZZ2OmDcA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r7ylz-00CQ5n-W8; Tue, 28 Nov 2023 14:09:12 +0000 Date: Tue, 28 Nov 2023 14:09:11 +0000 From: Matthew Wilcox To: Chris Li Cc: "Fabio M. De Francesco" , Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ira Weiny , Nhat Pham Subject: Re: [PATCH] mm/zswap: Replace kmap_atomic() with kmap_local_page() Message-ID: References: <20231127160058.586446-1-fabio.maria.de.francesco@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 28 Nov 2023 06:10:44 -0800 (PST) On Mon, Nov 27, 2023 at 12:16:56PM -0800, Chris Li wrote: > Hi Fabio, > > On Mon, Nov 27, 2023 at 8:01 AM Fabio M. De Francesco > wrote: > > > > kmap_atomic() has been deprecated in favor of kmap_local_page(). > > > > Therefore, replace kmap_atomic() with kmap_local_page() in > > zswap.c. > > > > kmap_atomic() is implemented like a kmap_local_page() which also > > disables page-faults and preemption (the latter only in !PREEMPT_RT > > kernels). The kernel virtual addresses returned by these two API are > > only valid in the context of the callers (i.e., they cannot be handed to > > other threads). > > > > With kmap_local_page() the mappings are per thread and CPU local like > > in kmap_atomic(); however, they can handle page-faults and can be called > > from any context (including interrupts). The tasks that call > > kmap_local_page() can be preempted and, when they are scheduled to run > > again, the kernel virtual addresses are restored and are still valid. > > As far as I can tell, the kmap_atomic() is the same as > kmap_local_page() with the following additional code before calling to > "__kmap_local_page_prot(page, prot)", which is common between these > two functions. > > if (IS_ENABLED(CONFIG_PREEMPT_RT)) > migrate_disable(); > else > preempt_disable(); > > pagefault_disable(); > > >From the performance perspective, kmap_local_page() does less so it > has some performance gain. I am trying to think would it have another > unwanted side effect of enabling interrupt and page fault while zswap > decompressing a page. > The decompression should not generate page fault. The interrupt > enabling might introduce extra latency, but most of the page fault was > having interrupt enabled anyway. The time spent in decompression is > relatively small compared to the whole duration of the page fault. So > the interrupt enabling during those short windows should be fine. > "Should" is the famous last word. Interrupts are enabled with kmap_atomic() too. The difference is whether we can be preempted by a higher-priority process.