Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp99374pxf; Tue, 16 Mar 2021 23:49:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw87CZpCddX+AwJ1rJKDJZVrN5PTd5rf+hLaF/H0Y8h59PMIPt8k+AvsI7Ns6v0vHligZ3n X-Received: by 2002:a17:906:b80c:: with SMTP id dv12mr33899789ejb.110.1615963790348; Tue, 16 Mar 2021 23:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615963790; cv=none; d=google.com; s=arc-20160816; b=oDf7rdRbV5J0ahkPLdJt82ISfM/CfQTT+87M+02VTAUVzEubQJZKd1+FoX0krHbYIs /LBiYAnBrBM+uOylXdkTejOaewIFm5iPRdh93f+vVMzwR3DzXg0mronSeN/zAYKaLjIg El+uwwDHpg9QoUxEqGd3V/CbHks0qaHzIewqCVSBTV1MjKjaSoEJyxIPxySqT9I9dVv5 WxIVpSiyiV0heIVuSr27isIPUkbJFJZMZz/6xBERD4tG1T0qN/tl+EtMt8FQQ+xgcJqF sUbsBLZJTFj7+2DBXtPGYD4mbKBk8xfJmCEt7ahlkx0E8XGwvtXfzq2Eo5tvx0G5B1ea 9oxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=8zRXU7uth3Ds6N3u87/rKINv0QWNuT4fVBZRt+g/Go0=; b=jxgopEb35r6urvKscCcrM8V22PKxUckszqYgexVRt8WRQokpFTKdXx/O5WdbgvwKw2 0VZY48YK8sqIyt47fl3UUAlZW0pBlqrGRYuPuoFX2aL9i1o3ROQ2TuyfeL/ZySYVi/wr qJP9/toZmQD3jisa9ZaaL4XO+rUyS7XNdO2sr4zDtxDfp2llDnAuyRJIJy2Ph1XDbM0/ qNE1xxJSuJwyv+OZ9yyk0zxkkIyiDdm+lT1ba9OKmNPojaDWlaSSh78kdSV4XrALH+0n wAeRybxfXeSDHxz8qPWqq7xGM2q5T53FOfd9qNt8Jiij9rVuQd/RBSkv344LG4ugpheN LDeg== ARC-Authentication-Results: i=1; mx.google.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cf26si15253388ejb.702.2021.03.16.23.49.28; Tue, 16 Mar 2021 23:49:50 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230112AbhCQGpa convert rfc822-to-8bit (ORCPT + 99 others); Wed, 17 Mar 2021 02:45:30 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:3367 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230026AbhCQGp1 (ORCPT ); Wed, 17 Mar 2021 02:45:27 -0400 Received: from DGGEML404-HUB.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4F0gZr1BwQz5c4h; Wed, 17 Mar 2021 14:43:00 +0800 (CST) Received: from DGGEML509-MBS.china.huawei.com ([169.254.4.125]) by DGGEML404-HUB.china.huawei.com ([fe80::b177:a243:7a69:5ab8%31]) with mapi id 14.03.0513.000; Wed, 17 Mar 2021 14:45:13 +0800 From: "chenjun (AM)" To: Dan Williams CC: Matthew Wilcox , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , Jan Kara , "Xiangrui (Euler)" , "lizhe (Y)" , yangerkun , "zhangyi (F)" , Joao Martins Subject: Re: [question] Panic in dax_writeback_one Thread-Topic: [question] Panic in dax_writeback_one Thread-Index: AdcWSusQwspXlegvQqCtsylm2CuWCw== Date: Wed, 17 Mar 2021 06:45:13 +0000 Message-ID: References: <20210311121923.GU3479805@casper.infradead.org> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.178.53] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for the advices. I will check out that. 在 2021/3/17 12:55, Dan Williams 写道: > On Tue, Mar 16, 2021 at 8:00 PM chenjun (AM) wrote: >> >> 在 2021/3/12 1:25, Dan Williams 写道: >>> On Thu, Mar 11, 2021 at 4:20 AM Matthew Wilcox wrote: >>>> >>>> On Thu, Mar 11, 2021 at 07:48:25AM +0000, chenjun (AM) wrote: >>>>> static int dax_writeback_one(struct xa_state *xas, struct dax_device >>>>> *dax_dev, struct address_space *mapping, void *entry) >>>>> ----dax_flush(dax_dev, page_address(pfn_to_page(pfn)), count * PAGE_SIZE); >>>>> The pfn is returned by the driver. In my case, the pfn does not have >>>>> struct page. so pfn_to_page(pfn) return a wrong address. >>>> >>>> I wasn't involved, but I think the right solution here is simply to >>>> replace page_address(pfn_to_page(pfn)) with pfn_to_virt(pfn). I don't >>>> know why Dan decided to do this in the more complicated way. >>> >>> pfn_to_virt() only works for the direct-map. If pages are not mapped I >>> don't see how pfn_to_virt() is expected to work. >>> >>> The real question Chenjun is why are you writing a new simulator of >>> memory as a block-device vs reusing the pmem driver or brd? >>> >> >> Hi Dan >> >> In my case, I do not want to take memory to create the struct page of >> the memory my driver used. > > There are efforts happening to drastically reduce that overhead. You > might want to check out Joao's work [1]. I think that direction holds > more promise than trying to extend FS_DAX_LIMITED. > > [1]: http://lore.kernel.org/r/20201208172901.17384-1-joao.m.martins@oracle.com > >> And, I think this is also a problem for DCSSBLK. > > If I understand correctly DAX replaced XIP for S390. There have not > been reports about this problem, and I can only guess because XIP > (eXecute-In-Place) is a read-only use case where dax_writeback_one() > is never triggered, or S390 just isn't using DCSSBLK anymore. The last > time I touched FS_DAX_LIMITED the DCSSBLK maintainers offered to just > delete this driver to get it out of the way. > >> >> So I want to go back the older way if CONFIG_FS_DAX_LIMITED >> >> diff --git a/fs/dax.c b/fs/dax.c >> index b3d27fd..6395e84 100644 >> --- a/fs/dax.c >> +++ b/fs/dax.c >> @@ -867,6 +867,9 @@ static int dax_writeback_one(struct xa_state *xas, >> struct dax_device *dax_dev, >> { >> unsigned long pfn, index, count; >> long ret = 0; >> + void *kaddr; >> + pfn_t new_pfn_t; >> + pgoff_t pgoff; >> >> /* >> * A page got tagged dirty in DAX mapping? Something is seriously >> @@ -926,7 +929,25 @@ static int dax_writeback_one(struct xa_state *xas, >> struct dax_device *dax_dev, >> index = xas->xa_index & ~(count - 1); >> >> dax_entry_mkclean(mapping, index, pfn); >> - dax_flush(dax_dev, page_address(pfn_to_page(pfn)), count * PAGE_SIZE); >> + >> + if (!IS_ENABLED(CONFIG_FS_DAX_LIMITED) || pfn_valid(pfn)) >> + kaddr = page_address(pfn_to_page(pfn)); >> + else { >> + ret = bdev_dax_pgoff(mapping->host->i_sb->s_bdev, pfn << >> PFN_SECTION_SHIFT, count << PAGE_SHIFT, &pgoff); > > This is broken: > > mapping->host->i_sb->s_bdev > > ...there is no guarantee that the superblock associated with the > mapping is hosted on the same block device associated with the passed > in dax_device. See dax_rtdev in xfs_open_devices(). > -- Regards Chen Jun