Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5290889imw; Wed, 20 Jul 2022 02:52:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uNtrRLL75tyIlOTUTamYFPd9ya3C5QRmmKdgM1hMH1nr7+gAVuPOBl31AQQqv1YQI3kYPT X-Received: by 2002:a17:906:99c1:b0:6fe:b01d:134 with SMTP id s1-20020a17090699c100b006feb01d0134mr34857447ejn.598.1658310735301; Wed, 20 Jul 2022 02:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658310735; cv=none; d=google.com; s=arc-20160816; b=zXzJwnWfk+44ODjBuYQyZJI0M0FBhZAKI48AR1i348PrPfrMnGZS+MZchG93yvZCT8 FUAY7yymxt4OHvCMsXC0dxOrl7aKPK1U8lCIWrqM4rqkNkbGbPRP8It8LxRAH55livfs fyQW1UfSbqBAtZi0xOILU5J8zVgMHrZl62Ogu1XY38zx/qrTPHpIA80PMaMjjcvlGOWl gyr/uQQiA1gPdCSWmj3pkNfF4Vb3+R7SRLtr4dUCCmwWrwWm0RFyVjL+2kJatZx665vU e/eX4wTDGjWKYp9KtfXZO02e3YxOp7oUTy8hwYeCj4Kgt3bIZE/dLuPRUjeR9QwbPGb8 DZVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=MZf52wwvVpiIrpw4WdkFCukb/S5Zxk/n0tVsxHtYz3s=; b=UkKcburogcvH3l8DOZt3T8xJolcsrme78q5+1Z6SrBNMp7nUMk+S5t9YGQfTyoFrUy pFuDSxtltztJ4jiqlRnTJjMSSS/Iwjvam3T2nuPYOnYoHeIM9TZW3SnDWfsi7rSe0z6A Y+NbF9ZeVRpfA/mDBYsEKdo2Z1K5mqf0a02Sfz1MVqcWoxvdxv+fHN/ilaepMzW1mPKg BPpkOKjoesfOBxfMGlsr2bpxUwJMEt9G8XIK9XFPKnkJAdZAAFI/ZbJdGai8zX09wkjD qHK0whrUkt5yuKoP3GNx8wK0mqxiwRRjUalB5tivUFXYpW3owqlXdDk2MhsAgHRP+YCP eyfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S4ozL+iu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p2-20020a056402500200b0043572af468asi950258eda.522.2022.07.20.02.51.50; Wed, 20 Jul 2022 02:52:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S4ozL+iu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229470AbiGTJR2 (ORCPT + 99 others); Wed, 20 Jul 2022 05:17:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbiGTJR1 (ORCPT ); Wed, 20 Jul 2022 05:17:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C09B02A73A for ; Wed, 20 Jul 2022 02:17:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 22420617EB for ; Wed, 20 Jul 2022 09:17:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE623C3411E; Wed, 20 Jul 2022 09:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658308644; bh=0zBO6umFFIrPrU7UNFUykMRqo+BjUg3C8nb2Lh1VYyA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=S4ozL+iug/6wm07GUIQUZ4Z2Awe27I83BkiycWryzvxkLp2BTN0DMSBdRZ7EzPEZH Ytt/0e4GJzdbQ2RDKIauTx+oJZrhV7vP4GCgY7aDqjCAjQmNRVPxOWWaRr0EkEBqJk gCMl4zssRtQGVIzf8FLMzeaicZHmUwKENIdQ6ZEk/iS95bJDeFTOxwrmAs52+L6GjN 2Cc9R15r5KX07Amhh1D7KPlXEJbvVZjGEaojkIiLm9AEIA5KdrhWmKq79EpH0YPqkG P8ISZpVshT8s7FoUIvPrdmCK0G0U4LJU1xDdD5zCCZjWpwLemLYzSsVbUsubkUP4jI RZLGDyFjfRrjg== Date: Wed, 20 Jul 2022 10:17:16 +0100 From: Will Deacon To: Anshuman Khandual Cc: Barry Song <21cnbao@gmail.com>, "Huang, Ying" , Andrew Morton , Catalin Marinas , LAK , Linux-MM , Steven Price , Andrea Arcangeli , =?utf-8?B?6YOt5YGl?= , hanchuanhua , Johannes Weiner , Hugh Dickins , LKML , Minchan Kim , Yang Shi , Barry Song , =?utf-8?B?5byg6K+X5piOKFNpbW9uIFpoYW5nKQ==?= Subject: Re: [RESEND PATCH v3] arm64: enable THP_SWAP for arm64 Message-ID: <20220720091716.GA15752@willie-the-truck> References: <20220718090050.2261-1-21cnbao@gmail.com> <87mtd62apo.fsf@yhuang6-desk2.ccr.corp.intel.com> <87zgh5232o.fsf@yhuang6-desk2.ccr.corp.intel.com> <416a06f6-ca7d-d4a9-2cda-af0ad6e28261@arm.com> <05639c8d-73f7-7e12-9941-cae3037e44b4@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 20, 2022 at 08:06:42AM +0530, Anshuman Khandual wrote: > On 7/20/22 07:16, Barry Song wrote: > > On Tue, Jul 19, 2022 at 4:04 PM Anshuman Khandual > > wrote: > >> On 7/19/22 09:29, Barry Song wrote: > >>> On Tue, Jul 19, 2022 at 3:35 PM Anshuman Khandual > >>> wrote: > >>>> On 7/19/22 08:58, Huang, Ying wrote: > >>>>> Anshuman Khandual writes: > >>>>>>>> How about the following? > >>>>>>>> > >>>>>>>> static inline bool arch_wants_thp_swap(void) > >>>>>>>> { > >>>>>>>> return IS_ENABLED(ARCH_WANTS_THP_SWAP); > >>>>>>>> } > >>>>>>> > >>>>>>> This looks good. then i'll need to change arm64 to > >>>>>>> > >>>>>>> +static inline bool arch_thp_swp_supported(void) > >>>>>>> +{ > >>>>>>> + return IS_ENABLED(ARCH_WANTS_THP_SWAP) && !system_supports_mte(); > >>>>>>> +} > >>>>>> > >>>>>> Why ? CONFIG_THP_SWAP depends on ARCH_WANTS_THP_SWAP. In folio_alloc_swap(), > >>>>>> IS_ENABLED(CONFIG_THP_SWAP) enabled, will also imply ARCH_WANTS_THP_SWAP too > >>>>>> is enabled. Hence checking for ARCH_WANTS_THP_SWAP again does not make sense > >>>>>> either in the generic fallback stub, or in arm64 platform override. Because > >>>>>> without ARCH_WANTS_THP_SWAP enabled, arch_thp_swp_supported() should never > >>>>>> be called in the first place. > >>>>> > >>>>> For the only caller now, the checking looks redundant. But the original > >>>>> proposed implementation as follows, > >>>>> > >>>>> static inline bool arch_thp_swp_supported(void) > >>>>> { > >>>>> return true; > >>>>> } > >>>>> > >>>>> will return true even on architectures that don't support/want THP swap. > >>>> > >>>> But the function will never be called on for those platforms. > >>>> > >>>>> That will confuse people too. > >>>> > >>>> I dont see how. > >>>> > >>>>> > >>>>> And the "redundant" checking has no run time overhead, because compiler > >>>>> will do the trick. > >>>> I understand that, but dont think this indirection is necessary. > >>> > >>> Hi Anshuman, Hi Ying, > >>> Thanks for the comments of both of you. Does the below look ok? > >>> > >>> generic, > >>> > >>> static inline bool arch_wants_thp_swap(void) > >>> { > >>> return IS_ENABLED(CONFIG_THP_SWAP); > >>> } > >>> > >>> arm64, > >>> > >>> static inline bool arch_thp_swp_supported(void) > >>> { > >>> return IS_ENABLED(CONFIG_THP_SWAP) && !system_supports_mte(); > >>> } > >>> > >>> caller, > >>> > >>> folio_alloc_swap(struct folio *folio) > >>> { > >>> > >>> if (folio_test_large(folio)) { > >>> - if (IS_ENABLED(CONFIG_THP_SWAP)) > >>> + if (arch_thp_swp_supported()) > >>> get_swap_pages(1, &entry, folio_nr_pages(folio)); > >>> goto out; > >>> } > >> > >> Current proposal in this patch LGTM, I dont see any reason for these changes. > > > > OK, thanks, Anshuman. Can I collect this as a Reviewed-by? > > Yes please. > > Reviewed-by: Anshuman Khandual I've lost track of exactly what the outcome here is, so Barry, please can you send a final version of the agreed-upon patch? Thanks, Will