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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C34C6C4332F for ; Mon, 17 Oct 2022 06:59:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbiJQG7M (ORCPT ); Mon, 17 Oct 2022 02:59:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbiJQG7I (ORCPT ); Mon, 17 Oct 2022 02:59:08 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4211819281; Sun, 16 Oct 2022 23:59:07 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id j23so12798141lji.8; Sun, 16 Oct 2022 23:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=3eKWV3ZnNjGmxLIU+eSsnyLxu6igTVT8zL8/KZHEyfE=; b=ULCMVuisMAVondNv3Qbd6taxl1211DmPh5RUhFIO3JzsPKLGMG4WHSWy92PX0ZRQb9 dCg0XTX2vcYf8McVzR9AxFC0d9pcE3rc7gpIqm7weeuvAzu0J0mBxQqaY5Nq04w4zsRF eJz4VYLwSt5hfhpujxeVUSt32FihHROSDmRV5Z9sEUOOHkLG6ySzqh4JmMKyQxY65bKC UNbtoMQ6IWMpH4SqIzofi4Xdi4SS71tSZ1OIAeE2HUqhWseSNq1ABF2frDCLu0n0msD7 /8hvIqm78IDifI5qOuX/rRoyxmspOOHZeoRv2vfDVqHvmaGNASYcUrylAH+wJrissucT PLwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=3eKWV3ZnNjGmxLIU+eSsnyLxu6igTVT8zL8/KZHEyfE=; b=oWK9jVk6R1a1kSVq4igLwSeLfdQ+XnqFXNVGUl82zX45fHEmeIVOWBtkugubInUpEj yU7GuBDWqCMi9lw84ufCKZBshRBsiVMx4Iyw8zNZTI+rmwF2CvEqsvvUKvxObw5ytjAp BWyh9AU8b2VUfcLx0SMgFLKPsIZs2ljVIXpGYGWu+cpems9MWrVOb2m14ylxu2NAYSD3 k02DYAoVxMPJhnIVfZ/1P47wH+8tnP22qZRcxatxNQr7xi1QjCf5uRoeuCMeyE633If8 o2xfPQ3zvDBP5b7xIcAa+JQGE6LUIemYDipCS8RjZOIQ7wrGKEGnNynuTiiQmNIhDvaY /KqQ== X-Gm-Message-State: ACrzQf0W2VpSrXclzGly1l8D21LeJpEzMD9tjCyRCfROnhoS3NcoWopK ZjghGGb7cA5CV07N6VG5Wde6DehaftLnrwUFI9q3jeHL49A= X-Google-Smtp-Source: AMsMyM7frChQl+feuZyDV+ee1f4QRfiaspPBOzN9qzHg/ei+IIM3Q/XmXCurcINYzfwXfDhCMnmB0DldiPPlGchdlxM= X-Received: by 2002:a2e:bea3:0:b0:26f:de79:dc2e with SMTP id a35-20020a2ebea3000000b0026fde79dc2emr3288714ljr.92.1665989945450; Sun, 16 Oct 2022 23:59:05 -0700 (PDT) MIME-Version: 1.0 References: <1665725448-31439-1-git-send-email-zhaoyang.huang@unisoc.com> In-Reply-To: From: Zhaoyang Huang Date: Mon, 17 Oct 2022 14:58:36 +0800 Message-ID: Subject: Re: [RFC PATCH] mm: move xa forward when run across zombie page To: Matthew Wilcox Cc: "zhaoyang.huang" , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, ke.wang@unisoc.com, steve.kang@unisoc.com, baocong.liu@unisoc.com, linux-fsdevel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 17, 2022 at 1:34 PM Zhaoyang Huang wrote: > > On Fri, Oct 14, 2022 at 8:12 PM Matthew Wilcox wrote: > > > > On Fri, Oct 14, 2022 at 01:30:48PM +0800, zhaoyang.huang wrote: > > > From: Zhaoyang Huang > > > > > > Bellowing RCU stall is reported where kswapd traps in a live lock when shrink > > > superblock's inode list. The direct reason is zombie page keeps staying on the > > > xarray's slot and make the check and retry loop permanently. The root cause is unknown yet > > > and supposed could be an xa update without synchronize_rcu etc. I would like to > > > suggest skip this page to break the live lock as a workaround. > > > > No, the underlying bug should be fixed. > > > > > if (!folio || xa_is_value(folio)) > > > return folio; > > > > > > - if (!folio_try_get_rcu(folio)) > > > + if (!folio_try_get_rcu(folio)) { > > > + xas_advance(xas, folio->index + folio_nr_pages(folio) - 1); > > > goto reset; > > > + } > > > > You can't do this anyway. To call folio_nr_pages() and to look at > > folio->index, you must have a refcount on the page, and this is the > > path where we failed to get the refcount. > OK, could I move the xas like below? > > + if (!folio_try_get_rcu(folio)) { > + xas_next_offset(xas); > goto reset; > + } sorry, It seems the above suggestion doesn't break the loop. update it by moving one step and goto retry instead of restarting from ROOT. if (!folio_try_get_rcu(folio)) { xas_next_offset(xas); goto retry; }