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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B20AC48260 for ; Fri, 16 Feb 2024 07:14:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09DF28D000E; Fri, 16 Feb 2024 02:14:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 04D788D0001; Fri, 16 Feb 2024 02:14:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E57328D000E; Fri, 16 Feb 2024 02:14:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D54F28D0001 for ; Fri, 16 Feb 2024 02:14:02 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6D12E801B9 for ; Fri, 16 Feb 2024 07:14:02 +0000 (UTC) X-FDA: 81796802724.20.A465049 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by imf15.hostedemail.com (Postfix) with ESMTP id A940DA0009 for ; Fri, 16 Feb 2024 07:14:00 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=L9CV60Cj; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of hughd@google.com designates 209.85.128.181 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708067640; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Fl1Nnwwt1Iw6MB9TRmkKxycKApOS/hToxGMtYRxh2Bk=; b=y+DjuX6i0SS10/iMK2AA2POvHq64Ts3clLNoX+TBHv6bkWCdR3zDFYGsBrK85EMje9MtWs udXsb3DetAEwrLFWrlLCd2NzS2Xia3U/OV9vza7PbcEj9WjSNB8F/qTclK6oAJqGRjuQEP mzoqY9cKAixcSt5c1RW9jzrAdxccyzk= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=L9CV60Cj; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of hughd@google.com designates 209.85.128.181 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708067640; a=rsa-sha256; cv=none; b=jGXBvN6/VlqYYmikLVgqu6n4exusBZjrxOl66lqRO2nTyTWja2lUXHzFJBw9HjY2qUK9ig q86X/4Wr8tRLZ/eyhmsAF62lSWg/wAQsr5upQpscZ8aab+C8Sp5h3+Elg2aKfLF+g/LcqX UjHIwwskwSu/s18HkEJKo6N1uJelvT8= Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-607c5679842so18242447b3.2 for ; Thu, 15 Feb 2024 23:14:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708067640; x=1708672440; darn=kvack.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=Fl1Nnwwt1Iw6MB9TRmkKxycKApOS/hToxGMtYRxh2Bk=; b=L9CV60Cjl4xka6vLI78slnJSGyRhAqhQCgjVCe00GlIxj9LmCd1do5eDZX3vzQMfFH WLTAcfuwg5CUxv1Fd77Crzm9WBoW2cC7YMpcxbMqRb/uBuSRe+vyXgfugQsimH3g0FZD aiaYLrHudehiiDVZFk1Ks8qYE2LCvY8lSmiCImHzrl32GPChSC9BmTBQFyQaZJxszzPj AJnQ0xfmUXGOzYu4y+DvtADgeftTHI18FjjEVp5LEtM6o5p31t/INFTlhPsU+j88NiT1 4MiS6oGiDlsf94xtWwxxn/JFNYRIRdoB3z2VT72aZesT69d/umZ6gNoTfweZQqzRv1rT U6qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708067640; x=1708672440; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Fl1Nnwwt1Iw6MB9TRmkKxycKApOS/hToxGMtYRxh2Bk=; b=vdYrjhwa91aW0ahQplFvax9/4DjdRnIVrS1HCeQY9+55gDCv9f1JUTYHkIN6eoNX9t QghW+1S/X1b7S3teyAoIdqHY6o8JJCZpsW/eVR2p9VCfFt8Jtab+01awVTZxzjlLsqZ+ yXv5etp2R5zmxWitZd19RH6piFY0loELY2eVq0zR52uwXDHRYpdPaH/RBjHejI0lJFxb q8rCxEvVq7Myes7O3p1hoDyVojk6iZv79CfCnmMY5ZaCgal4CuJcPkqylhVDZQ5tBL2W sYTNhiY41+D/jI8jKp05BY7KYAsPjZzkafvtc3/Rj0R9ShItCghXNouFy1z37Lj4YCWe 8Bgg== X-Forwarded-Encrypted: i=1; AJvYcCWoZvan3EWyU0hsGylqrd+eUCR/M1Ov8LAjWMjIJ6cMtfvqYieHHCFyzW5a/xB7ofqxfISoyQZtA9T11XOzqgXhVi4= X-Gm-Message-State: AOJu0Yz9X6rFZnoPDejc+H/FugvFN6h2p7CEMLZYg9AHOzItAG8DF37c yAa7SG+9SXUEpnLvZ65twm6ElPNyYTrsQWdo1CkeXf0IfI6eJISCA47DYXQ8ig== X-Google-Smtp-Source: AGHT+IHQXBygKVY+3o1Oh9WEFcmDSpRmo15pPlLAd7Q37IfMN6zmt/CFgRRxWVCWRR/2+18/7RaMTw== X-Received: by 2002:a0d:cc48:0:b0:607:855f:599d with SMTP id o69-20020a0dcc48000000b00607855f599dmr4064915ywd.14.1708067638057; Thu, 15 Feb 2024 23:13:58 -0800 (PST) Received: from darker.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id i123-20020a816d81000000b0060795309574sm236649ywc.79.2024.02.15.23.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 23:13:57 -0800 (PST) Date: Thu, 15 Feb 2024 23:13:55 -0800 (PST) From: Hugh Dickins To: Christoph Hellwig cc: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton , Matthew Wilcox , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 13/20] xfs: don't allow highmem pages in xfile mappings In-Reply-To: <20240129143502.189370-14-hch@lst.de> Message-ID: References: <20240129143502.189370-1-hch@lst.de> <20240129143502.189370-14-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: A940DA0009 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 8hnpnf49jp9mjfy6khno41j4ukcxi59f X-HE-Tag: 1708067640-294130 X-HE-Meta: U2FsdGVkX19L4TDwQtagtiw7hrYm2IIAuXr8GxUBlmKZN6W+q/Y9Ji0Cp5W8BL+UBzzTywhLETmREl3kaVQkIgkSREEGOzIQLWQisT0+BqrLfD2UTnk7yKPfP1AYH7ikvTP0VT/Tp8cJgCqmjSCcaVyCONJrPKEQnvojHaGrW9XeMw100/NwOdZBM0xZEPE+/C0EOpOkxg1P6WszrihsqY6JfOPmmM1bKl0X616r5BtKbf/fJc3mL1I0++l1ueOxUi3weX+8kNh7X7cgCG+ndlY4DpKBMtzJRiGWOKGPByjy9lhIeP8jqLuECzmaAocPqBEhUnGrxfmkZwjtwd7ZYQhcYV4cSDceVEEVP9Ivxtd7HR7angIHkc3kihD0/wtJSAl18QOTCPTfK0iZow2ql5YjzLVPWtW9Cbcs5VOTgebUfDgcWcp9Zp31DpDCfWBpXBRnLqqE5v5VG4SvG9zsSUoWHMffMoPW68lbnj6IioJ5GcuMprsCEFoxL2/HPhIx/GCcfMKeGLChV8JB+Sp8/ejCFFOtmKAzYnY1R5Z9/hmLzFRsMF44LvvwrQPBAqKPk1LnANUAqnwZbq13GoG7tL/mfH6XbVjGnG0nWZ596Boe2mOhuuvtnve1soX6m44ymifQnTd0RZgJXG0kbICdgJTnG4zDop0bI+bKpqVIrRNH6u7QnWMDIZZKrsXPY8zUWsQfV2ILpmRjN0RzmHYoLqCVk7sZhL0srORFDRV3niY5fIo7lJpSCAztH/zbWn57JHc6hZj7Q210jmwyxYN/tepWG1ezeZmK7JgTgWhUV4M94WFFzwmr9/cRndwVJYibCgTEs/Tra6+1/LxRqG7PfsanK1I5EWzCmaurz1+ihRmqIU/FRSwiCNGHUEnT/MNfJs3KutG3OyOMKld4dwm2A1asSBXdhpR+3SfW7hk9NfzKl4Q/D8M2AWeK6BtAwpbq2hXIA8Gn49a8nbR96CG oQnI3YoF tYWeysrKC7VEOAK05eQlPbf4OZyPCEOJ2EHoEM5i9Ala18XcrIswZVJKqWrEp2gTk/1cQte80r+1MSJwaukPt9TEt7kDB0p+EFlZqJk1BZBnNl3I6tOfv0yePtUuU9mgZKHdAFSbCSh7UIHI0iy7kfj7bnYcBmVPw/0tKQS9vvcrgj2amu6P/Tmc8YIk2dt+y7zfEWXT5LDx9TuaTmfTxr70ufUxodBE/+XTDVMbN1ougpspE3hZE/CIrbWbDbXEpXkPcbxjDOYbbzmfbflRR8T3zc2ecIyArCEOB/qD3IgnOb1lTZ5ltqU69kRtqdR5pMezSPhW7l4ts5e1Mv9GonKfhUvkTp8DltVHh41E41g9dbnOZQomWLzuEuj0zIe9XPnGVqFiaxPVd00NjuPpANmCNK1oi89MTPBHa X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon, 29 Jan 2024, Christoph Hellwig wrote: > XFS is generally used on 64-bit, non-highmem platforms and xfile > mappings are accessed all the time. Reduce our pain by not allowing > any highmem mappings in the xfile page cache and remove all the kmap > calls for it. > > Signed-off-by: Christoph Hellwig > Reviewed-by: Darrick J. Wong > --- > fs/xfs/scrub/xfarray.c | 3 +-- > fs/xfs/scrub/xfile.c | 21 +++++++++------------ > 2 files changed, 10 insertions(+), 14 deletions(-) > > diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c > index 95ac14bceeadd6..d0f98a43b2ba0a 100644 > --- a/fs/xfs/scrub/xfarray.c > +++ b/fs/xfs/scrub/xfarray.c > @@ -580,7 +580,7 @@ xfarray_sort_get_page( > * xfile pages must never be mapped into userspace, so we skip the > * dcache flush when mapping the page. > */ > - si->page_kaddr = kmap_local_page(si->xfpage.page); > + si->page_kaddr = page_address(si->xfpage.page); > return 0; > } > > @@ -592,7 +592,6 @@ xfarray_sort_put_page( > if (!si->page_kaddr) > return 0; > > - kunmap_local(si->page_kaddr); > si->page_kaddr = NULL; > > return xfile_put_page(si->array->xfile, &si->xfpage); > diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c > index 7e915385ef0011..a669ebbbc02d1d 100644 > --- a/fs/xfs/scrub/xfile.c > +++ b/fs/xfs/scrub/xfile.c > @@ -77,6 +77,12 @@ xfile_create( > inode = file_inode(xf->file); > lockdep_set_class(&inode->i_rwsem, &xfile_i_mutex_key); > > + /* > + * We don't want to bother with kmapping data during repair, so don't > + * allow highmem pages to back this mapping. > + */ > + mapping_set_gfp_mask(inode->i_mapping, GFP_KERNEL); I had been going to point you to inode_nohighmem(inode), which is how that is usually done. But I share Matthew's uncertainty about cpusets and the __GFP_HARDWALL inside GFP_USER: you may well be right to stick with GFP_KERNEL, just as you've done it here. I suppose it depends on whether you see this as a system operation or a user-invoked operation. I did also think that perhaps you could mask off __GFP_FS here, to avoid having to remember those memalloc_nofs_save()s elsewhere; but that's probably a bad idea, I doubt anywhere else does it that way. So, no change required, but I wanted to think about it. Hugh > + > trace_xfile_create(xf); > > *xfilep = xf; > @@ -126,7 +132,6 @@ xfile_load( > > pflags = memalloc_nofs_save(); > while (count > 0) { > - void *p, *kaddr; > unsigned int len; > > len = min_t(ssize_t, count, PAGE_SIZE - offset_in_page(pos)); > @@ -153,10 +158,7 @@ xfile_load( > * xfile pages must never be mapped into userspace, so > * we skip the dcache flush. > */ > - kaddr = kmap_local_page(page); > - p = kaddr + offset_in_page(pos); > - memcpy(buf, p, len); > - kunmap_local(kaddr); > + memcpy(buf, page_address(page) + offset_in_page(pos), len); > put_page(page); > > advance: > @@ -221,14 +223,13 @@ xfile_store( > * the dcache flush. If the page is not uptodate, zero it > * before writing data. > */ > - kaddr = kmap_local_page(page); > + kaddr = page_address(page); > if (!PageUptodate(page)) { > memset(kaddr, 0, PAGE_SIZE); > SetPageUptodate(page); > } > p = kaddr + offset_in_page(pos); > memcpy(p, buf, len); > - kunmap_local(kaddr); > > ret = aops->write_end(NULL, mapping, pos, len, len, page, > fsdata); > @@ -314,11 +315,7 @@ xfile_get_page( > * to the caller and make sure the backing store will hold on to them. > */ > if (!PageUptodate(page)) { > - void *kaddr; > - > - kaddr = kmap_local_page(page); > - memset(kaddr, 0, PAGE_SIZE); > - kunmap_local(kaddr); > + memset(page_address(page), 0, PAGE_SIZE); > SetPageUptodate(page); > } > > -- > 2.39.2