Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp236806imu; Mon, 19 Nov 2018 21:33:38 -0800 (PST) X-Google-Smtp-Source: AJdET5doawk0u/s7fJPLxYE2huqCztqM+dh2fQbZ55gNXQwSQh6/lTG/EsuuPOHUz899MN0DOPiq X-Received: by 2002:a62:3305:: with SMTP id z5mr807362pfz.112.1542692018155; Mon, 19 Nov 2018 21:33:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542692018; cv=none; d=google.com; s=arc-20160816; b=iSWm2c+slo3QEmpiz+KTQJYY7G2Q1ixegbh/IJ+4+zXU9++WUjMvFzBOpAksdGB8rG Avi8SiOyuH53NGk4eR6QCkXxuviH9/K1QzUHN8uH+4ovDwPIv6u2cxQY6qbb3BRDwohk XOynV2Nfl+ZjR5+Q0RV+lg81b2EvKD7TFgRrHl1Bg7/NRVNK5jgQ6p0RH/KTpdTgQFEr f94WcQrYMYrmHjmW8azByY7CCERtqdYPrj83tWnrV+WnPTApBvPetGYZ/jbQuUCqQI/H yjUujoFKAPJR2AEWUNNT4lqju/fIdiDUhyOJzqvfDku8a9aMr46FzstDn3PhkH0Nd8jm iP5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=LHluP8cAaDm0ch8NnG3ZRGKPbbjJbamWEl7mWptBzqo=; b=a+ZevWeBC6lkyZ0jdc4TOGaHisSP/uzACGzdGdXgm5X0n/CbkHU5lvH888K3B8AlXu UW9oLl0LqQv4VIBQqQhxfCdW6GKEAQJe0kc0mE1NDnCYFEbNJksSOGAUj070q0vKmbln Co+DB5CoBMP7Ekeam/5leLNQsOwxQnA1XE3/ddvSs9m0vtsgCzTTlAVnwBMF4UqzOR/M jNRLYShFYvMTtdsLwLvgzqQsxEn0SEGyoiH7W1Bal0VUgPg97VMgvub0BDZbG6cXfE9Y 8DJLZ4ed1VyGCnkILjKCQ0mceD6TYwEz3UsxCH2j6GSX3hZmKOgGrpOJarUbekbefXNJ PF3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jnTZqB2j; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1si21445737pfn.111.2018.11.19.21.33.23; Mon, 19 Nov 2018 21:33:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jnTZqB2j; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730710AbeKTPeu (ORCPT + 99 others); Tue, 20 Nov 2018 10:34:50 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:37295 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730230AbeKTPet (ORCPT ); Tue, 20 Nov 2018 10:34:49 -0500 Received: by mail-pf1-f193.google.com with SMTP id u3-v6so400754pfm.4 for ; Mon, 19 Nov 2018 21:07:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=LHluP8cAaDm0ch8NnG3ZRGKPbbjJbamWEl7mWptBzqo=; b=jnTZqB2jhS4t0l0DWQgcAC1AFIjJdso7mqRUSQ0YD4zHm6fmD8qEb5bYnKasnKFsq0 msQu7JNnA3MrX2sl0SiKSwkS+9l67wsbZtmx0cZto6ULbXRxDvbUQ5szQEMo/Uv1Xsm7 A5eRij0E7f6ZRw3sFrmqyOEpKfUviEXPKrdPjgUfqFiQuvNGMKl4FgF/UJY3eeZ35Rbw ZuN6dpqWu3WgKy3ol0EE1KGzb21uaGY4eGrMqNqpDfmi+3kuvLolaLo4Dp+Odi7HfQlm uRUUcKQ6tR0A+7T7bU5Cm7f8jeE8xwDlN5m0EZPvtFlIw8q67nlxql5SK0zWtylGMQ3K AQvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=LHluP8cAaDm0ch8NnG3ZRGKPbbjJbamWEl7mWptBzqo=; b=aU936PFW7yORYBOWUcys798iTgwvyFDHYOHobh2CozQVlu6TwMI+DwGm1keZ6Kp+MM U9nuVngApO9lyk3mnrP03N0DlTdad984tNOXrg4kFR5pPhjAS3WpMikhYFOQ4+wz0ZBd qjF8TxHJn+4TaS8qHqC8qhUISblvvsdAVZvjhAjPGmAsIg9wjthFCTuNPwanEYXdQ6jF mjkGMM3WK1twXliR6QLIeTVWmgbm0yjGrPEBSbmrKUNsH36V5FF9ETaSvPywKvHco4T4 BHZUBL87hHt7KFGLVku3627CDTWuRQ/r1sKUyUTGExBHElsfBnKZFbD6CzTfBlU6J/JL HpTg== X-Gm-Message-State: AGRZ1gKETswYyTkGMz1ozxi0VBuwSwi+1Ni64vgCaZOigHUu1ZwQvV8j jtw+5kfjYJui2RjSrOwJ86K85g== X-Received: by 2002:a62:8145:: with SMTP id t66mr711418pfd.55.1542690457214; Mon, 19 Nov 2018 21:07:37 -0800 (PST) Received: from [100.112.89.103] ([104.133.8.103]) by smtp.gmail.com with ESMTPSA id f13sm23117889pfa.132.2018.11.19.21.07.36 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Nov 2018 21:07:36 -0800 (PST) Date: Mon, 19 Nov 2018 21:07:27 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Yu Zhao cc: Hugh Dickins , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm: fix swap offset when replacing shmem page In-Reply-To: <20181120012950.GA94981@google.com> Message-ID: References: <20181119004719.156411-1-yuzhao@google.com> <20181119010924.177177-1-yuzhao@google.com> <20181120012950.GA94981@google.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 19 Nov 2018, Yu Zhao wrote: > On Mon, Nov 19, 2018 at 02:11:27PM -0800, Hugh Dickins wrote: > > On Sun, 18 Nov 2018, Yu Zhao wrote: > > > > > We used to have a single swap address space with swp_entry_t.val > > > as its radix tree index. This is not the case anymore. Now Each > > > swp_type() has its own address space and should use swp_offset() > > > as radix tree index. > > > > > > Signed-off-by: Yu Zhao > > > > This fix is a great find, thank you! But completely mis-described! > > Yes, now I remember making swap offset as key was done long after per > swap device radix tree. > > > And could you do a smaller patch, keeping swap_index, that can go to > > stable without getting into trouble with the recent xarrifications? > > > > Fixes: bde05d1ccd51 ("shmem: replace page if mapping excludes its zone") > > Cc: stable@vger.kernel.org # 3.5+ > > > > Seems shmem_replace_page() has been wrong since the day I wrote it: > > good enough to work on swap "type" 0, which is all most people ever use > > (especially those few who need shmem_replace_page() at all), but broken > > once there are any non-0 swp_type bits set in the higher order bits. > > But you did get it right when you wrote the function, which was before > the per swap device radix tree. so > Fixes: f6ab1f7f6b2d ("mm, swap: use offset of swap entry as key of swap cache") > looks good? Oh, you're right, thank you. Yes, the fix is to that one, in 4.9 onwards. I don't much like my original use of the name "swap_index", when it was not the index in a swapfile (though it was the index in the radix tree); but it will become a correct name with your patch. Though Matthew Wilcox seems to want us to avoid saying "radix tree"... Hugh