Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1880685lqz; Mon, 1 Apr 2024 23:34:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZFihVWzZ3At8P2s+iPeokpBNFdP4bddezeA5PPKgPakssBCDN5d4jwQ9nzBhflzyG+9nr3PAc3HjWL3jhFM9b6pR8qUOwCfUxAs6GeQ== X-Google-Smtp-Source: AGHT+IGBjcl9rCulriyDlxLhvbMZzBIBZGwPz3f1HIaWrqC3aXHE+yfMd1v2USVxf/giBxrQSc1S X-Received: by 2002:a17:906:f75a:b0:a4e:2a5b:f94 with SMTP id jp26-20020a170906f75a00b00a4e2a5b0f94mr7733998ejb.6.1712039641287; Mon, 01 Apr 2024 23:34:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712039641; cv=pass; d=google.com; s=arc-20160816; b=kpbbSVZ6isEpR84NdJ6o6yerYH6OnX3MBlLr9AgYVkbyTOIdc2fXI6dPrGGFfiIcuI MsULNku4c2aBAqfPJm2lVSKPgjDOKKVa9lmSdoHqEZPemHUBvdjGrcLVGR9ny5ld8tpe keFPOuH0FySvNqtjiIDMkSPKMEBBz1s6Y8YRxzUS5EqEsNzThCTEuQk5SBDIroBWcmnD MewcMYx/NdwkWzSOA9TkySJ2Xa+KJdRbEZ777RTkGp58W/i93sHRB61YWhObc1UshnrS WYAwuR0WcC/H0wwq4S83WwrmFvUJCMrAbBVlZDzByz4r/57n2Hz3w2cfFX+U+UyrGvqT 73mg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=WfJZUXB0Wucy4wWsY3edrboz9hVbKA+JvOoaZXPXl/s=; fh=ciy8ej0uL9/4eINrtbX2y8g4KCIceYqiqeKEbwqepiM=; b=qFr02w5j6mljO4VmR4rjvgH286ymF6RsbGyvy1wkReMT9yd8rGztieL4sEqggXaTwW mhw3Tm07/3BCsk1z5ygAjhrVgSijS6jKYpQsB8jCCl0BL0uMFPWrqYgHja3Hv/OVV91n KxUzoKEOzisIj1ULntGJVaULiAhztd2eM7pNJW9R8NbjV3dopEM+PreAWPgSlCEUzG4c 3KCKBdBTpWTyiqzv9+LDkDisAU368jmIJSisN/7Pj51WQ4ZCqA4s7jjbSUpATrRVycdS /alnlZ+MIsNG9ylS+oAsIfbGyr6PbCEKhvkcYeqiIsspiF3zW0hVw1Pg7u6dlrZfkJI+ NTWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PRWe0NAO; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-127446-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127446-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id an3-20020a17090656c300b00a473533abc4si5044949ejc.766.2024.04.01.23.34.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 23:34:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127446-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PRWe0NAO; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-127446-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127446-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0AA1D1F216D3 for ; Tue, 2 Apr 2024 06:34:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E37DB24B23; Tue, 2 Apr 2024 06:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PRWe0NAO" Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65EC5241E2 for ; Tue, 2 Apr 2024 06:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712039635; cv=none; b=Nf7BfAFympAePJMdayvpxGkAKs86GF1E7O2gjHd9lVUZZl2twSEfOcV/0LpVVUup8ABg2mlLvGYGPhEyNnjyRb3JY2DCHgCwJfpYsVty63V35JJrEUTpcjtCIUkqggHCe2be4rB8lFvTvX0Q+xEvWQfJ2BQXOzui8otRSxv0V/Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712039635; c=relaxed/simple; bh=WfJZUXB0Wucy4wWsY3edrboz9hVbKA+JvOoaZXPXl/s=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ibfhRNqG6SKbC5DjplUcDCd/3kSrbNRoR+ClPigjQRM0tHMhodAft4Y2Rk7NhJdBBaAl7+nqNuOFyQ77Vtn6fsXRWfk/wE6VRAZaPGdSm2IRJtALStosRzM9058TXUOAJNiihVSJuE5AcaF1shv2MddD1tWitVsNALk7c3eBupQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PRWe0NAO; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2d8129797fcso26284181fa.1 for ; Mon, 01 Apr 2024 23:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712039631; x=1712644431; 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=WfJZUXB0Wucy4wWsY3edrboz9hVbKA+JvOoaZXPXl/s=; b=PRWe0NAOejAmXQ3ITqRqMOjDbRWeR+WlTlWmvA9sWSXfABUNJmc4SAyay4Wno4aY0j XrJotDT+oy5RZC40WK7/doXUnClCtulww7MUTcb31XuA+dIYcOnRTNwOaGMVbHC7EbHw QlvchKbBAF5djQCiWp4+t3P1Zn6oXCMDujY/z30I9/ulj38BHymSjPWmqu8vSFyoGNCc PKQkJGd+67Cgc7mlKFZo0CGZfYTJrLFbSsGYGZZIzUmVD8N4NeXeOkOQGw+/Hyc/CRwA +rdwv0iTFjpklHIrxnA24cyqPwNARtCon23gNaY/7r2unRlozlATsHkIVeHVODTj0j+1 y4ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712039631; x=1712644431; 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=WfJZUXB0Wucy4wWsY3edrboz9hVbKA+JvOoaZXPXl/s=; b=uAdQTATJiCYJvcTY5lmqAU+yK1IPqk/oHn7A5eOyCd8Xew8fJ0oryvPD/ZHR2xAnBc 7S2bEyrDhIsA+MagNhYOEwxlnW4W5ztjY682JV3CN38NOyIMIbn0NrUDked0PmQz23bY QQSFkNI+SfDLuIkgdr2Cp16Jl9TJ6057jHMRKGJF3KZNv28auf7Q+09tAR0l5CjmsSuI 6om3x18xXfFhMoSzOitwlOevZSA8p/T7PLsg7qNqssTa5C5wrJGVYK6JGEtWg8EkRtT4 aF9o+OZB2GIxeh9yFkNcQ3kUfT7MUmQL1JDTomBoiX5bhh0b2WoQ7tnv8dRcOBpyYEi3 dROg== X-Forwarded-Encrypted: i=1; AJvYcCUw9IYzvxq18Y+xxhHA4V5iYWj2HU5Fvd89oQZBSblZd5mo8+dx8nPYuwqIMOGXvts03/5DA+YbVXj+Sz9mjGpwA6//ZcSLRI7QG308 X-Gm-Message-State: AOJu0Yz9cunCiiyD4d5LZB7NbN5DcC1V+ece6+6JhcwLzqxBklU8kehl ZbwbmVwcqs3gtYU6HCf0vujp0zGraJIgJhFrRZXt/T9Xl95KrriMvn6TTPRofDqMexgkCkD+clq C7ejeMg5JrBdBd1YimppDSXE9DII= X-Received: by 2002:a2e:954e:0:b0:2d7:1ce5:3e24 with SMTP id t14-20020a2e954e000000b002d71ce53e24mr5521022ljh.34.1712039631218; Mon, 01 Apr 2024 23:33:51 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240401081734.1433755-1-zhaoyang.huang@unisoc.com> In-Reply-To: From: Zhaoyang Huang Date: Tue, 2 Apr 2024 14:33:39 +0800 Message-ID: Subject: Re: [PATCHv2 1/1] mm: fix unproperly folio_put by changing API in read_pages To: Matthew Wilcox Cc: "zhaoyang.huang" , Andrew Morton , NeilBrown , linux-mm@kvack.org, linux-kernel@vger.kernel.org, steve.kang@unisoc.com, Christoph Hellwig Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 2, 2024 at 8:34=E2=80=AFAM Matthew Wilcox = wrote: > > On Mon, Apr 01, 2024 at 04:17:34PM +0800, zhaoyang.huang wrote: > > From: Zhaoyang Huang > > > > An VM_BUG_ON in step 9 of [1] could happen as the refcnt is dropped > > unproperly during the procedure of read_pages()->readahead_folio->folio= _put. > > This is introduced by commit 9fd472af84ab ("mm: improve cleanup when > > ->readpages doesn't process all pages")'. > > This patch is no less bullshit than the last time you posted it. > I explained why here: > https://lore.kernel.org/linux-mm/ZgQRtQ60mrvOUKXo@casper.infradead.org/ Yes. I get your point in your previous feedback. Could you please check the timing sequence in v2's commit message, where the folio_lock failed to prevent the race from happening. I also would like to insist that the refcnt got from alloc_pages just paired with the one which is checked in __remove_mapping but any other folio_put. The sequence of read_pages->readahead_folio->folio_put happens to be right when no race and then frees the folio immediatly.