Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp58031pxb; Wed, 13 Jan 2021 23:14:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwo0Ft4v8+x6SC6D2A+kfKMPSTahJnhJYozol9rE6hsvmXUglcEqhJpw8WKoyGfxiJNdUZ8 X-Received: by 2002:a05:6402:312c:: with SMTP id dd12mr4798320edb.327.1610608457170; Wed, 13 Jan 2021 23:14:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1610608457; cv=pass; d=google.com; s=arc-20160816; b=nlzei7GUwZqDhWOc0TR6U0t7qNxeLzWc0Kxc+xA52exuvI5JSG28vPzBuvMBVQVTw9 hp5JjGoCwyd8yQPk56aQVQk/9Mo8zDh2Qg6eCXTFzLJWzcjY9w9HPx/EN5BFWpeBlDhX j0x+VcjL/nP7YnJ0J4LJ2yCppIXloigmai6qMAnWU+0oRfkz2duVmAPUObghx8uNsrpD 4I1zCkwQtJkl1KAksbUWdUVV4In4+2sQmRaGyBuc0ApUwvrJ36Emux3XbPCtfOjJ0Ma2 HARgvn/KLzDv3j2VWCPFMr3DBjm2yCcnleWPcvnUhzFxAvXrT6bQUY7t9GiEape586LP 8JuA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=/epOgBd/BBd/spKFK8yIXz6IEDtr5Bo50kl9YxlZ8Xk=; b=iBeM93V53kr8uj9L/dW2mo4guilt1ioh1bjLiKUXgIOu24sZYUw8Ej9ZGyXmqFL+AR ep0zOiF22zLvj3kzp2an166k61VwymgvozWDCHSTiv1+avYK9kIG4FmGpqv+nvUDzmkC Z0oFSPYYhvxBvR0lzF7cf01TJ5PuX/GJDT+FWvt5i6gyjPA6mbWA2/wnF+p7EbPThb1s 10ezMjcspP6EI65vHLqNK/L0m8aVxF3EFBHivSxPyjBmLCrQ7BDkNAEEfJx0qcJH/364 kBahRAFBaF5ECEm45s1sg0ScXRgmlwQhC5nioPH8S84b3HZ7iLOirkS5FoSV5HUW8Csm 5EQA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nec.com header.s=selector1 header.b=j79MjcEn; arc=pass (i=1 spf=pass spfdomain=nec.com dkim=pass dkdomain=nec.com dmarc=pass fromdomain=nec.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v10si2144563ejj.392.2021.01.13.23.13.53; Wed, 13 Jan 2021 23:14:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nec.com header.s=selector1 header.b=j79MjcEn; arc=pass (i=1 spf=pass spfdomain=nec.com dkim=pass dkdomain=nec.com dmarc=pass fromdomain=nec.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726478AbhANHMo (ORCPT + 99 others); Thu, 14 Jan 2021 02:12:44 -0500 Received: from mail-eopbgr1400043.outbound.protection.outlook.com ([40.107.140.43]:24988 "EHLO JPN01-TY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725888AbhANHMo (ORCPT ); Thu, 14 Jan 2021 02:12:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lEDZ5QKYpNhcbECJNbZbn/7BtOr5txXBH3oX9n6YH++e6KOCJ8GB9Tm7zh/rjiwz8ZAGleYpGrdV2U/MeI+IKrdicHbHiSEPbU9sfSeiOKXHDR2oiMDo12D2b1ESf5GqP52hJoL+po3JldWcsSpmw64RQA5X51vENHQZ1aw7qSKPAboWKvW3ErTfRCG00ZVE3Rf6T61Ey8bN3PokCdP/ZAPtLJwnQKODKTep6FQJftpRbRTxYD07JDnehHtbEaEJCLBmsxqNdbvg/f7F8V0OKmHEXcHf2bOnnl8GDEfa0TdDGoEA/Gpqee+kKYNeqVxF5A5jF55hPwWwywNJRexKvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/epOgBd/BBd/spKFK8yIXz6IEDtr5Bo50kl9YxlZ8Xk=; b=jB4Nr0Zi40vDLvPM4QlT105yUqxY8HgRrPQdJYA4r2xYJdDJ7/OLzgaiUvv39k66B7sH8Qhp3AnByANvI1okcKQtnKNBBCdpG+6nrcNa7+jwslfNlLuV7rFX/PqT62n40x8bZXYTftgvVFshlPxzHuZ1ZR+4CYSMUzyiRsacA/gZBgJ7FDxaUj1hDY2fDqD2RfU/MwDeYw5M1VKaJyy50SUFmyvfD9zLE7i8b1+NtdodTnXfhVdkZyzId1ybK8+lXOhQLIwuSkLp1i2sMkzthDAgy41hNVuckvMBWJb9+NbVKBmutlDc5VWOVpxA0cWpeZnNCoORofJXI8bSzR4Zcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nec.com; dmarc=pass action=none header.from=nec.com; dkim=pass header.d=nec.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nec.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/epOgBd/BBd/spKFK8yIXz6IEDtr5Bo50kl9YxlZ8Xk=; b=j79MjcEnm62PQquPI7AyNoHnVrVr5fIXUzGlTB8+6Tg2MuwtfAGbsumx7qL5VMlehksSm3gy3m3xrfqaaQ9EOoXFLSHWc0pRCcrx/a+JMNM9SjEdhoqFssd4gsfKRIYKLhvbl5IKQqXV6V24Zy0LdH4eg/MsBnZBJ38ug2qt5IM= Received: from TY1PR01MB1852.jpnprd01.prod.outlook.com (2603:1096:403:8::12) by TYAPR01MB3965.jpnprd01.prod.outlook.com (2603:1096:404:c6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Thu, 14 Jan 2021 07:10:25 +0000 Received: from TY1PR01MB1852.jpnprd01.prod.outlook.com ([fe80::8453:2ddb:cf2b:d244]) by TY1PR01MB1852.jpnprd01.prod.outlook.com ([fe80::8453:2ddb:cf2b:d244%7]) with mapi id 15.20.3763.010; Thu, 14 Jan 2021 07:10:25 +0000 From: =?iso-2022-jp?B?SE9SSUdVQ0hJIE5BT1lBKBskQktZOH0hIUQ+TGkbKEIp?= To: Dan Williams CC: "akpm@linux-foundation.org" , Naoya Horiguchi , Michal Hocko , David Hildenbrand , Oscar Salvador , "stable@vger.kernel.org" , "linux-mm@kvack.org" , "linux-nvdimm@lists.01.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v4 4/5] mm: Fix page reference leak in soft_offline_page() Thread-Topic: [PATCH v4 4/5] mm: Fix page reference leak in soft_offline_page() Thread-Index: AQHW6heInkqG7QE910OSp4LbdxOpwqompd+AgAAOmQA= Date: Thu, 14 Jan 2021 07:10:25 +0000 Message-ID: <20210114071024.GC16873@hori.linux.bs1.fc.nec.co.jp> References: <161058499000.1840162.702316708443239771.stgit@dwillia2-desk3.amr.corp.intel.com> <161058501210.1840162.8108917599181157327.stgit@dwillia2-desk3.amr.corp.intel.com> <20210114014944.GA16873@hori.linux.bs1.fc.nec.co.jp> In-Reply-To: Accept-Language: ja-JP, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=nec.com; x-originating-ip: [165.225.110.205] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 99c42390-46cb-4e0e-4dc6-08d8b85b770c x-ms-traffictypediagnostic: TYAPR01MB3965: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8EA9dXroqEbxcJFg30hj2s68dyQfhtkaFxnsILsK2j8gGhe1JmZPOVeSWcnOL2Lic3LQA90V041uG9nau1kQy++kBPkgcF5g/tCy/S9AzmcPisTqMXnNRZ54oeJKVwkVwTXrMRhBQ7RKMha3aPG55bBpjOrhLBcJIoIHzTHUVHw548PVyGjNqRM6hjm3klIK+I+t6SOovRujRAy7ebe80fyvsNIi8TlmDIwTqSv1tIzRHUV5xSSfoeq5isHuUIb65wmgVHKDrfNy6tpbXxAEXXGxpZRyUQSkAok21QfS4dGGGdkYdvljCpO35OvYwkpht8gEoYB/lLYMaUqFII8tfgKXQ7Wpy3QOzMs//v2xkWk7v5D6m6n+dOjb4UdT9kyOKIcI6eJgcctNO7UjVPjIyw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TY1PR01MB1852.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(346002)(396003)(376002)(366004)(136003)(6486002)(66446008)(26005)(54906003)(5660300002)(86362001)(6512007)(6916009)(33656002)(478600001)(9686003)(71200400001)(7416002)(4326008)(1076003)(8936002)(66556008)(66946007)(55236004)(76116006)(186003)(66476007)(8676002)(85182001)(53546011)(83380400001)(64756008)(6506007)(316002)(2906002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-2022-jp?B?NzJid1A2eFdDOHlVM2d5ZFRUOStRWFNkaEFrSU9GKzAwWmZpcXNpNXhW?= =?iso-2022-jp?B?TWtlZHRlQmt1cEtQUExXcEI5Um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vkb0dyRm54ZDhZUVJwVUdUY1pMWG50NG5RcXFQOXhLUFZHT05zYlRR?= =?iso-2022-jp?B?dFJudTB2b2pPM2hQRldsUm5KcUNkb2dtMkUyOUlLanRpQ0dBcGxJMzNn?= =?iso-2022-jp?B?dGt4Mmdhdng4TmN6Wk1KSzhjb2g3MXZVZmNRbk02NDdVWEVSc1BTTENY?= =?iso-2022-jp?B?Mmk0UmM1cUVOUzVqYjhrSjRrSXY3V29xNWZDNEVuQndZeGlDWndadnNv?= =?iso-2022-jp?B?N1VhN3EwSFhrNG5CajJycXoySWpJRHVDS1d5a0N3d2hUT1VnRTBkWW54?= =?iso-2022-jp?B?aklsbWxHYWNla1VtcmM4Zno0dkdxaTVDc0VHcU9ncHIxYXgyNXU5TmZB?= =?iso-2022-jp?B?UGZ5SHlMQnI0Yy8zVmd3dHN0MENod2tZazhvNWZhc0QxSlh2UThsN2hR?= =?iso-2022-jp?B?Tno2bWNuNXRrNFZDeVE2UDB3M0IvcmJzeFRWREVuOWJESmpob2xTMTRx?= =?iso-2022-jp?B?UU5JQzA4R1lDbVB3OXBBVw==?= Content-Type: text/plain; charset="iso-2022-jp" Content-ID: <4C74EAC17EFC2D42B38E717AAF84678B@jpnprd01.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nec.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TY1PR01MB1852.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99c42390-46cb-4e0e-4dc6-08d8b85b770c X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jan 2021 07:10:25.1145 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: e67df547-9d0d-4f4d-9161-51c6ed1f7d11 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: KD2mf9YVU3Q1VduIk5Esoww47M46nkPwsrHqqjSEoWk9LpTJgq1d2T4qY7/41HiRcb1OcqLzduNmf2xsiJ8dOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYAPR01MB3965 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 13, 2021 at 10:18:09PM -0800, Dan Williams wrote: > On Wed, Jan 13, 2021 at 5:50 PM HORIGUCHI NAOYA(=1B$BKY8}!!D>Li=1B(B) > wrote: > > > > On Wed, Jan 13, 2021 at 04:43:32PM -0800, Dan Williams wrote: > > > The conversion to move pfn_to_online_page() internal to > > > soft_offline_page() missed that the get_user_pages() reference taken = by > > > the madvise() path needs to be dropped when pfn_to_online_page() fail= s. > > > Note the direct sysfs-path to soft_offline_page() does not perform a > > > get_user_pages() lookup. > > > > > > When soft_offline_page() is handed a pfn_valid() && > > > !pfn_to_online_page() pfn the kernel hangs at dax-device shutdown due= to > > > a leaked reference. > > > > > > Fixes: feec24a6139d ("mm, soft-offline: convert parameter to pfn") > > > Cc: Andrew Morton > > > Cc: Naoya Horiguchi > > > Cc: Michal Hocko > > > Reviewed-by: David Hildenbrand > > > Reviewed-by: Oscar Salvador > > > Cc: > > > Signed-off-by: Dan Williams > > > > I'm OK if we don't have any other better approach, but the proposed cha= nges > > make code a little messy, and I feel that get_user_pages() might be the > > right place to fix. Is get_user_pages() expected to return struct page = with > > holding refcount for offline valid pages? I thought that such pages ar= e > > only used by drivers for dax-devices, but that might be wrong. Can I as= k for > > a little more explanation from this perspective? >=20 > The motivation for ZONE_DEVICE is to allow get_user_pages() for "offline"= pfns. I missed this point, thank you. >=20 > soft_offline_page() wants to only operate on "online" pfns. Right. >=20 > get_user_pages() on a dax-mapping returns an "offline" ZONE_DEVICE page. OK. >=20 > When pfn_to_online_page() fails the get_user_pages() reference needs > to be dropped. The background is clear to me, and I agree with this patch. Reviewed-by: Naoya Horiguchi >=20 > To be honest I dislike the entire flags based scheme for communicating > the fact that page reference obtained by madvise needs to be dropped > later. I'd rather pass a non-NULL 'struct page *' than redo > pfn_to_page() conversions in the leaf functions, but that's a much > larger change. As Oscar mentions in another email, removing MF_COUNT_INCREASED was recently discussed and rejected. I think that if pfn-page conversion layer is somehow factored out from soft/hard offline handler, code would be more readable/maintainable. Thanks, Naoya Horiguchi=