Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp243738rdh; Thu, 23 Nov 2023 02:52:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFi66hUz1HbGkBkmwCIN+KlgS74mk/V6ZP7+dP4j3MZ/usx+F7Rg4Z3MLElrLcbF2y3lg1v X-Received: by 2002:a05:6871:289d:b0:1f0:cc7:84c5 with SMTP id bq29-20020a056871289d00b001f00cc784c5mr6623599oac.11.1700736761383; Thu, 23 Nov 2023 02:52:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700736761; cv=none; d=google.com; s=arc-20160816; b=wlRDAF6gJSCsiniXP6tlLRd3V2OxKB81pCJOJxqs1hcD/f/Ne/GFeoaCeE+sz3CmoI QHFdueL1vX0n96m7J1leWzSunzZ9k2lio3Ao6e3uibAJ4Ptvjx2K0Rn0jk48HO14Q4Um wKfAdZdwkEqyfZNOk1JhM4av+d3xWOfETN/Tw1tnqd28hiY+OVyI17mEUlBRbF3Cdyyx JLkKEGHcVyh5ilE3EJH1FngNd6sokbdSI2JbQsJvb0FA9IezlqwDtTCMWDN+qIyG4C/I zLzv/uCHSUUAJS1NOMJ7hXAkWpZtnHYVhrmATJaVos6RdMWBHjmaVQzB/5QGwRlLbrhP ks5g== 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=KlBw+J1DKtTqdlCO/c1cUzIzbtROUCDGWtDerK3Z8as=; fh=mxM+iyYud2eqLtG0pkLKi0uG+kielFRY+hhtqFHmhjA=; b=tHoH+36I6UJj6XT44gg3s8Vzy3z1bEI5Z9BS/tuRyepxESsRafwYSFsslkb18cYjh1 Bq/DZAz7gxK0HY6vO1WUg73GGriJm3bG49jJ3LIQsxw2pWi84KUIj+wSKUwq7sMcipF6 atxwPEuYYUG2btApNmHYJiZBfq1zjLJR0HrIXA17p2B+q/+WAe901Gjqqoz1RrBBQO5o r6b3vnNUgVknZubA7YgSvIRhm6zuRdf51y+/i0IzKsQQVrfRhmPVRfFQCCQ8DqGhHlCs aUu6BC6KB85yi/nTsEn8dW+afoPp4LbzlLox7eGwXq8HBVfY4/z9HgbUf8wKr6ad4v1b 05iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TjpNstBk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id r2-20020aa79882000000b006cb8980fce1si977546pfl.356.2023.11.23.02.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 02:52:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TjpNstBk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 25F8A80C8408; Thu, 23 Nov 2023 02:52:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235213AbjKWKwY (ORCPT + 99 others); Thu, 23 Nov 2023 05:52:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235201AbjKWKwU (ORCPT ); Thu, 23 Nov 2023 05:52:20 -0500 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 475931BD for ; Thu, 23 Nov 2023 02:52:26 -0800 (PST) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2c887d1fb8fso9355791fa.0 for ; Thu, 23 Nov 2023 02:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700736744; x=1701341544; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=KlBw+J1DKtTqdlCO/c1cUzIzbtROUCDGWtDerK3Z8as=; b=TjpNstBkzm0o+js6eFXimRn0h62B8Mho/bxO56s1U3NIaixHwmQKkVewWB6c7ciW+9 8TUm+YzkpjacYpFSjorIIWWHyf0Pei2MsVRu1HshmPXSnMuO8Stwx+voa2BLTqz67p6y IAmHDS+GB3GHG8ZZ7BOShktMVao+UlC5Qp4AKp1mXn8uIel/yWTrd80wDEN+O8nFcdsE uOiMqnRI/NlvEmsmXsRikJlOomfgW/C+2vDrwzpm4IX8sBZySojsZSPuMrTPVhRWOYl7 0BoABxAOsCYzQtdoq3CtZTDFrzS5v1rzimAsAicy9kmcqb20HAnTAM95TsChp/GS4lG9 0Qvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700736744; x=1701341544; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KlBw+J1DKtTqdlCO/c1cUzIzbtROUCDGWtDerK3Z8as=; b=AcLe19lBldC3zfIiRRFZ5XKCTYLw2VmJ0foQCT2LDA+TDHLat2P1C2qeB4FszOVVHV 9Jiumv2iS4yE2xBHL7D/r+3e4/2xhSmzXtCZfUWYAqTTrxP94O7TVDM6nU5gOcjUDzhG ifUQGjFd+gdTq2KWZy6NsRYBim5C7Czi/hzX5bqVG8vXKPTiAmkXDM2HaeFq9dPUsvel i29Ok00Bk3CpPoBl1Cwr2o/6KdI4LDEIIkXrNetzbqRqU25DDJglL9x/wbsbXbTic+Ij OmoZLX4tDI38RQzwSn/Ux3E/MiC79QKpw24BT0aeW4KXrJ+N9KUhT18IDh1fjPB+NmEn aoOA== X-Gm-Message-State: AOJu0YxM+jGZDLb14eGeu+JQ+OCob9SyMRmGbdeQQCLkyHG4IKQqQ1Z2 nJa4PTBQRYDL763b9/OBXx08kZBWgGclMolWGEk= X-Received: by 2002:a2e:9b0f:0:b0:2c5:1ad3:7798 with SMTP id u15-20020a2e9b0f000000b002c51ad37798mr3042949lji.52.1700736744207; Thu, 23 Nov 2023 02:52:24 -0800 (PST) MIME-Version: 1.0 References: <20231119194740.94101-1-ryncsn@gmail.com> <20231119194740.94101-9-ryncsn@gmail.com> In-Reply-To: From: Kairui Song Date: Thu, 23 Nov 2023 18:52:06 +0800 Message-ID: Subject: Re: [PATCH 08/24] mm/swap: check readahead policy per entry To: Chris Li 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=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 23 Nov 2023 02:52:39 -0800 (PST) Chris Li =E4=BA=8E2023=E5=B9=B411=E6=9C=8821=E6=97=A5= =E5=91=A8=E4=BA=8C 15:54=E5=86=99=E9=81=93=EF=BC=9A > > On Sun, Nov 19, 2023 at 11:48=E2=80=AFAM Kairui Song w= rote: > > > > 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 global= ly. > > 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 swa= p_info_struct *si, swp_entry_ > > return data_race(si->flags & SWP_SYNCHRONOUS_IO) && __swap_coun= t(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_rota= te_swap); > > + return data_race(si->flags & SWP_SOLIDSTATE) && READ_ONCE(enabl= e_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= si->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. Thanks, I'll improve this part.