Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp214806rdf; Mon, 20 Nov 2023 23:54:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEs8zADWvmp00USm75XGq0Eueomss1aDrNwivOFBKHh9/C9mMSfzoIuZ1vvZwzByZyllwQt X-Received: by 2002:a05:6a20:430e:b0:18a:e4ed:cc41 with SMTP id h14-20020a056a20430e00b0018ae4edcc41mr1250149pzk.23.1700553284409; Mon, 20 Nov 2023 23:54:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700553284; cv=none; d=google.com; s=arc-20160816; b=ADjv3u0lwzReHalQCDoTZ73ohue7zgBzc+vt4BdmnEB9G1BFuzKz1uxXC6vJA7ZwTc x28+Cy4SjmIWthw15iOt14wbB4hxzK9tO893SCVD05SzgVyOP5v9+KnCCmeTj9B4UDJX czxxDZIbmHkWcpJMRufjhdmnBPVkWEaQGl9WiuGAgUduvzFsvUKtmJRdujwxVXf4lpMQ oDvwPRxKn3TpCZsj51aMV34+SFHKOM2xXMK1EoGUTjd+MH+sP/i2BaLbGuE+DNHeLgEu jmCbR8CtFPoFcdJcnJAvvYjZ94sNijD8BTgtb8nFse4ARhSX9oTCtVwInvp3KMN46FDw Otnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=NyyrkZIL8UCzZl5kH2BTehXH7cUMxC7X5/MLJ+6Gr4w=; fh=v/j7QEwtsj+94eMIzch1qbwAijHXRMR6IcasrHCGlTE=; b=dia+dlMjc8rATDqwNF3UAd3gjt2L550woXRI18kqbA+w3IOkXE6IDHf/iSVKwC5+b7 1M761I8FzRxV+WSvlYdDUEX/CJ68ODNvQS+4AGlUvv3dx1V8JoPCfOXhT3w/NOlHiNTL Mmqybgqp9psPn+TCoIxlJvjyWpRC2o7y3vskPCNmrhZ0fkQyEA2byzwcSx9+oGjq8lx5 3BCSlXwhWellBP3M5OFoQnNiL0yQnn0cItEsjTqznmfNJui6Gt3NUTm1+jIQoQ5fwoYm RMKFZud7B9kZMjn2F470iX2FvTFoDOq0rl6ndyLioVpDq2trbuJ2Y3UbJxbDtx/vYIvB ggsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=elK63l9d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id p24-20020a63e658000000b005855f67e491si10063001pgj.696.2023.11.20.23.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 23:54:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=elK63l9d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 3573780DF270; Mon, 20 Nov 2023 23:54:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229484AbjKUHyn (ORCPT + 99 others); Tue, 21 Nov 2023 02:54:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjKUHyl (ORCPT ); Tue, 21 Nov 2023 02:54:41 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4102AF5 for ; Mon, 20 Nov 2023 23:54:38 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6AF3C43391 for ; Tue, 21 Nov 2023 07:54:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700553277; bh=0qqhbNpCfWQutTSkCiqeCJlRWmkVKXLvp8F0pOXn88U=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=elK63l9dFeOiW9NTleQIkzMSdLLpZXQhLUWaLipboebrlxya0h1PGeh363ua+QfNe 1h8SGgcQdV9CBXwHRnOFlw78vZN3Rpgeqh6FDtJ3+N7l/K81Qvn0FrblLIE1KEBtsx L05uAB6xWmaz9zGptoPTZjnbi5v8aYQAxsv6xvwP3Jr3t62OvLU30Mi8AAZ1ZBnm9F JNt+O2m/2Rt360Gwcty718OvyEVoLE/EORW9/yLOdFFwGBLQO6WxGYskMfxJVQ7fL0 JF8aZFw9qnyn9H+aU5kcJDAgfqRGhpU9SDFGivYOyC8x2Ma3Dr0KPjgactpoZw7pyw g3jZTFAZN4lfQ== Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2851967b945so1588918a91.1 for ; Mon, 20 Nov 2023 23:54:37 -0800 (PST) X-Gm-Message-State: AOJu0YyDnu+KvjIPSlq++dTuk9X3n99bbpF/pIrVC3FrRzOxHk28Fm3s pwLiiicfPLRzdK+kiKDWovx7qTDpggZhRrabOO06QA== X-Received: by 2002:a17:90b:3eca:b0:283:2805:7c7f with SMTP id rm10-20020a17090b3eca00b0028328057c7fmr2980093pjb.0.1700553277274; Mon, 20 Nov 2023 23:54:37 -0800 (PST) MIME-Version: 1.0 References: <20231119194740.94101-1-ryncsn@gmail.com> <20231119194740.94101-9-ryncsn@gmail.com> In-Reply-To: <20231119194740.94101-9-ryncsn@gmail.com> From: Chris Li Date: Mon, 20 Nov 2023 23:54:26 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 08/24] mm/swap: check readahead policy per entry To: Kairui Song Cc: linux-mm@kvack.org, Andrew Morton , "Huang, Ying" , David Hildenbrand , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 20 Nov 2023 23:54:43 -0800 (PST) On Sun, Nov 19, 2023 at 11:48=E2=80=AFAM Kairui Song wro= te: > > From: Kairui Song > > Currently VMA readahead is globally disabled when any rotate disk is > used as swap backend. So multiple swap devices are enabled, if a slower > hard disk is set as a low priority fallback, and a high performance SSD > is used and high priority swap device, vma readahead is disabled globally= . > The SSD swap device performance will drop by a lot. > > Check readahead policy per entry to avoid such problem. > > Signed-off-by: Kairui Song > --- > mm/swap_state.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/mm/swap_state.c b/mm/swap_state.c > index ff6756f2e8e4..fb78f7f18ed7 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -321,9 +321,9 @@ static inline bool swap_use_no_readahead(struct swap_= info_struct *si, swp_entry_ > return data_race(si->flags & SWP_SYNCHRONOUS_IO) && __swap_count(= entry) =3D=3D 1; > } > > -static inline bool swap_use_vma_readahead(void) > +static inline bool swap_use_vma_readahead(struct swap_info_struct *si) > { > - return READ_ONCE(enable_vma_readahead) && !atomic_read(&nr_rotate= _swap); > + return data_race(si->flags & SWP_SOLIDSTATE) && READ_ONCE(enable_= vma_readahead); A very minor point: I notice you change the order enable_vma_readahead to the last. Normally if enable_vma_reachahead =3D=3D 0, there is no need to check the s= i->flags. The si->flags check is more expensive than simple memory load. You might want to check enable_vma_readahead first then you can short cut the more expensive part. Chris