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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D540C43334 for ; Wed, 20 Jul 2022 09:17:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E89F6B0072; Wed, 20 Jul 2022 05:17:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 097C16B0073; Wed, 20 Jul 2022 05:17:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA0686B0074; Wed, 20 Jul 2022 05:17:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DB1B56B0072 for ; Wed, 20 Jul 2022 05:17:26 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A41A61C5C24 for ; Wed, 20 Jul 2022 09:17:26 +0000 (UTC) X-FDA: 79706924892.03.415E3FE Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 109DE140016 for ; Wed, 20 Jul 2022 09:17:25 +0000 (UTC) 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 19BDC61AF6; 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) ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=S4ozL+iu; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of will@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=will@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658308646; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MZf52wwvVpiIrpw4WdkFCukb/S5Zxk/n0tVsxHtYz3s=; b=LxU+/j4xMDktyJ/WCaoWV1u9Xtx8i5vCQuYY1DrmJjs98r3xYpYG582Rgvu67jE6yNgL4E Z5b63jmW9mi3mnbRAihLrt40oMYItFJBMumHoooYsDxM/Y6GSu70GWU/Wb+nXBG++mwQc8 MlWFiSnUIcOs4kH8pbTOVcS8D/Ep3lk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658308646; a=rsa-sha256; cv=none; b=ixHFDgZ2/uA2eZv8Y9IkoSNhgvhD43M9AYkPL7Y4BSQmPodi6krRJ0bapfMbeMB8E0g3kY u5Q95LtOO6Xnr9S9kKKZyERxUc/7trE+zvoc9OFHnFIjlHLUKgmDjP0g1yIdMmKNWcw7Q/ AaPb1DRaHYsO2Ep9VXE7cvX5OrXuRIY= X-Rspamd-Queue-Id: 109DE140016 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=S4ozL+iu; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of will@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=will@kernel.org X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: mfu4f8dt5nwmcnx56ajpkmfonqawnto1 X-HE-Tag: 1658308645-304013 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 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