Message ID | 20230205231704.909536-1-peterx@redhat.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1961783wrn; Sun, 5 Feb 2023 15:22:23 -0800 (PST) X-Google-Smtp-Source: AK7set84Qe2iSQVZEHu832z6uGLTGssyJuhgD0BySfcs8hb+Fm2QAz7jzG+jMA1P3MZ9/9sMNr6E X-Received: by 2002:a17:906:6a1b:b0:88f:8ef7:c71e with SMTP id qw27-20020a1709066a1b00b0088f8ef7c71emr15410622ejc.14.1675639343450; Sun, 05 Feb 2023 15:22:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675639343; cv=none; d=google.com; s=arc-20160816; b=zeSgxqu339cOWxWJ2nbRQ8J5Md7fgl6oNDPFXeloeNc6rZ4rwxVpBri2+A69BhZgV2 1k000OOxnGAE0jhQtnvNAUC/2Nvj2PPY+jln0IHQSKj833gFCx+nPEWMSQN+iUKmTsj0 4Y0D4vT24DgRcEpH7ei19L4fds6lByN/1hBg5sEYOl1GFfkYTZAOg5KWSAmg5lGMrowQ FEUX8OM2woUHISzucHaj+gEhHoim98aNXHx7zDyLLT4BAIYT8ffWFIhkTHwesPN4BH9A iO028d9IcuGKgsjLsSZ8Ac53/5e7DVjmGY5uE3tS18V7yqbdfUa4bawqOrv2423sSMbp T0qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=hczbFL+ar/tk/IYpzPCczVyi3teFQZrB1wxKh73TL0g=; b=tF0G5z7Z//R1tf5lVlpdC7oR/LS0ij7gW0ihcGXIIiUZv932xuw2P8pxqf541d8nzp eVrnMQ3vdShISz2FCn4oLiO8tjObhwjDee74/mHoAFvVwMYsXtGJQ3oCBxN/3p8dAu2s TIrqIIyCcTScMj8BcqA/I1nEjEdvdu4e8iicUBlds3/WVFMz8b5mdlXD1Za+NQRQ6Q+W 8nrUAfccalAu7oPpEADZHpoXAS2mOR7nTonPlYTh/koGLwXKKpgIn5gHYmELU1Jo3st4 DB+2AiLD0Ch/cErfKT/5+VVT6y/TxyRLvlGc9j1jMrJqCGTybkvmmhI7SJjYOLIga5iV 0UDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gLAF8qii; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id um37-20020a170907cb2500b0087d9362c240si9856621ejc.509.2023.02.05.15.22.00; Sun, 05 Feb 2023 15:22:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gLAF8qii; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229654AbjBEXSA (ORCPT <rfc822;kmanaouilinux@gmail.com> + 99 others); Sun, 5 Feb 2023 18:18:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbjBEXR5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 5 Feb 2023 18:17:57 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 119291968A for <linux-kernel@vger.kernel.org>; Sun, 5 Feb 2023 15:17:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675639028; h=from:from: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:content-transfer-encoding; bh=hczbFL+ar/tk/IYpzPCczVyi3teFQZrB1wxKh73TL0g=; b=gLAF8qii/iuEwBLmyjF0T1Y6jdTmzsBC9JuY0dGdh0wfaJT5S3EVu2dbG1NVRhRY5s3/qE N9oJQO4aR+tuSd4Tv5avZh18HY12a1KQrdBvMwzPxV/1bAT0qOGIqGET5XMhUQDeqVv7Qx TiHo+i9cLl60RIy6ikPdU2GrH0/l5dA= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-528-xdLjNT1pPCu_S-B8s8B-Cg-1; Sun, 05 Feb 2023 18:17:06 -0500 X-MC-Unique: xdLjNT1pPCu_S-B8s8B-Cg-1 Received: by mail-qk1-f198.google.com with SMTP id u11-20020a05620a430b00b007052a66d201so6892546qko.23 for <linux-kernel@vger.kernel.org>; Sun, 05 Feb 2023 15:17:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hczbFL+ar/tk/IYpzPCczVyi3teFQZrB1wxKh73TL0g=; b=CHZmEcz2SHCZZM4NVRrhkAtaSzJd1sNpQsldofPcL3/7CUiIAPWl8JjCuqLsV/dJTk GaHVrJl2rzK87F04wzbMueOQVIvmbLSeeec3q+S2xNaEp4lL6bIaVFxvhQ9qYl+Hkdp8 aDtxcbaO8TiSKXiYGg1P9yQjI5bvFLJmq0ZSgRkmIakPvg8D9dFlN9Zixna02UIPRUTt TJQDSHEOLW85kgRSXGW44GRPzFV3BqxnpH8pikdHztylfDk+8x037f6mEI1106XCcdIK A431Kdk8r0q4A+YS2sR5lPkmW6flwh7ZmI0D91EKu0vs1Ed27Gw1GBfNWYscYWaPvHma M6Tw== X-Gm-Message-State: AO0yUKU1n60eQnBoNk6+uEdCfBzeAAkFcAJpanvS6i5Uaqcp/AP+oji7 mheKSDtR+XqPb7fF5Ty0z9ZzfpHgD75Hj3QOQct5EEFIvwfkpNVji9pI+oKTBSW6a5JEM08KSHL yJFRB80KftJ5ACemooIuTdK9p X-Received: by 2002:a05:622a:a15:b0:3b8:695b:aad1 with SMTP id bv21-20020a05622a0a1500b003b8695baad1mr31166805qtb.1.1675639026387; Sun, 05 Feb 2023 15:17:06 -0800 (PST) X-Received: by 2002:a05:622a:a15:b0:3b8:695b:aad1 with SMTP id bv21-20020a05622a0a1500b003b8695baad1mr31166787qtb.1.1675639026141; Sun, 05 Feb 2023 15:17:06 -0800 (PST) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-56-70-30-145-63.dsl.bell.ca. [70.30.145.63]) by smtp.gmail.com with ESMTPSA id h26-20020ac8515a000000b003b82cb8748dsm5986545qtn.96.2023.02.05.15.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Feb 2023 15:17:05 -0800 (PST) From: Peter Xu <peterx@redhat.com> To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: peterx@redhat.com, Andrew Morton <akpm@linux-foundation.org>, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org Subject: [PATCH 0/3] mm/arch: Fix a few collide definition on private use of VM_FAULT_* Date: Sun, 5 Feb 2023 18:17:01 -0500 Message-Id: <20230205231704.909536-1-peterx@redhat.com> X-Mailer: git-send-email 2.37.3 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757035200047313693?= X-GMAIL-MSGID: =?utf-8?q?1757035200047313693?= |
Series |
mm/arch: Fix a few collide definition on private use of VM_FAULT_*
|
|
Message
Peter Xu
Feb. 5, 2023, 11:17 p.m. UTC
I noticed a few collision usage on VM_FAULT_* definition in the page fault path on arm/arm64/s390 where the VM_FAULT_* can overlap with the generic definition of vm_fault_reason. The major overlapped part being VM_FAULT_HINDEX_MASK which is used only by the hugetlb hwpoisoning. I'm not sure whether any of them can have a real impact, but that does not look like to be expected. I didn't copy stable, if anyone thinks it should please shoot. Nor did I test them in any form - I just changed the allocations from top bits and added a comment for each of them. Please have a look, thanks. Peter Xu (3): mm/arm: Define private VM_FAULT_* reasons from top bits mm/arm64: Define private VM_FAULT_* reasons from top bits mm/s390: Define private VM_FAULT_* reasons from top bits arch/arm/mm/fault.c | 8 ++++++-- arch/arm64/mm/fault.c | 8 ++++++-- arch/s390/mm/fault.c | 14 +++++++++----- 3 files changed, 21 insertions(+), 9 deletions(-)
Comments
On Sun, Feb 05, 2023 at 06:17:01PM -0500, Peter Xu wrote: > I noticed a few collision usage on VM_FAULT_* definition in the page fault > path on arm/arm64/s390 where the VM_FAULT_* can overlap with the generic > definition of vm_fault_reason. > > The major overlapped part being VM_FAULT_HINDEX_MASK which is used only by > the hugetlb hwpoisoning. > > I'm not sure whether any of them can have a real impact, but that does not > look like to be expected. I didn't copy stable, if anyone thinks it should > please shoot. Nor did I test them in any form - I just changed the > allocations from top bits and added a comment for each of them. This seems like a bad way to do it. Why not just put these VM_FAULT_* definitions in linux/mm_types.h? Then we'll see them when adding new VM_FAULT codes. Sure, they won't be used by every architecture, but so what?
On Mon, Feb 06, 2023 at 12:10:53AM +0000, Matthew Wilcox wrote: > On Sun, Feb 05, 2023 at 06:17:01PM -0500, Peter Xu wrote: > > I noticed a few collision usage on VM_FAULT_* definition in the page fault > > path on arm/arm64/s390 where the VM_FAULT_* can overlap with the generic > > definition of vm_fault_reason. > > > > The major overlapped part being VM_FAULT_HINDEX_MASK which is used only by > > the hugetlb hwpoisoning. > > > > I'm not sure whether any of them can have a real impact, but that does not > > look like to be expected. I didn't copy stable, if anyone thinks it should > > please shoot. Nor did I test them in any form - I just changed the > > allocations from top bits and added a comment for each of them. > > This seems like a bad way to do it. Why not just put these VM_FAULT_* > definitions in linux/mm_types.h? Then we'll see them when adding new > VM_FAULT codes. Sure, they won't be used by every architecture, but > so what? My initial version actually contains a few VM_FAULT_PRIVATE_N there, but I noticed only the minority uses that, especially there's s390 which takes 5 entries. I didn't had my mind straight on which's the best to go, then I removed them and posted this simpler version, with comment on each to fix the issues, more in a sense of raising the problem first. I agree it isn't a problem at all, not until 32 bits all used up. But that seems to slightly encourage more archs from using the new private entries which I wanted to avoid. If to take a closer look, we may not really need that much private entries. With s390, what I read is: - VM_FAULT_BADMAP could be replaced directly with VM_FAULT_SIGSEGV? - VM_FAULT_PFAULT could be replaced directly with VM_FAULT_BADCONTEXT? Then if I'm not wrong we can already reduce 5->3 private entries. I didn't directly change that because I am not 100% confident and I can't test them myself. It'll be great if arch people can have a look at either s390 and arm to see whether there's chance of simplifcations first. So the patchset is more of raising the collision issue first, meanwhile great to attract attention for arch people to refactor upon it. I can also try to reduce the private entries and introduce PRIVATE entries accordingly as you suggested, but I'll need more help on reviews and tests than this one. Thanks,
On Sun, Feb 05, 2023 at 07:54:35PM -0500, Peter Xu wrote: > On Mon, Feb 06, 2023 at 12:10:53AM +0000, Matthew Wilcox wrote: > > On Sun, Feb 05, 2023 at 06:17:01PM -0500, Peter Xu wrote: > > > I noticed a few collision usage on VM_FAULT_* definition in the page fault > > > path on arm/arm64/s390 where the VM_FAULT_* can overlap with the generic > > > definition of vm_fault_reason. > > > > > > The major overlapped part being VM_FAULT_HINDEX_MASK which is used only by > > > the hugetlb hwpoisoning. > > > > > > I'm not sure whether any of them can have a real impact, but that does not > > > look like to be expected. I didn't copy stable, if anyone thinks it should > > > please shoot. Nor did I test them in any form - I just changed the > > > allocations from top bits and added a comment for each of them. > > > > This seems like a bad way to do it. Why not just put these VM_FAULT_* > > definitions in linux/mm_types.h? Then we'll see them when adding new > > VM_FAULT codes. Sure, they won't be used by every architecture, but > > so what? > > My initial version actually contains a few VM_FAULT_PRIVATE_N there, but I That wasn't what I meant. I meant putting VM_FAULT_BADMAP and VM_FAULT_SIGSEGV in mm_types.h. Not having "Here is a range of reserved arch private ones".
On Mon, Feb 06, 2023 at 02:51:18AM +0000, Matthew Wilcox wrote: > That wasn't what I meant. I meant putting VM_FAULT_BADMAP and > VM_FAULT_SIGSEGV in mm_types.h. Not having "Here is a range of reserved > arch private ones". VM_FAULT_SIGSEGV is there already; I assume you meant adding them all directly into vm_fault_reason. Then I don't think it's a good idea.. Currently vm_fault_reason is a clear interface for handle_mm_fault() for not only arch pffault handlers but also soft faults like GUP. If handle_mm_fault() doesn't return VM_FAULT_BADMAP at all, I don't think we should have it as public API at all. When arch1 people reading the VM_FAULT_ documents, it shouldn't care about some fault reason that only happens with arch2. Gup shouldn't care about it either. Logically a new page fault handler should handle all the retval of vm_fault_reason afaiu. That shouldn't include e.g. VM_FAULT_BADMAP either. Thanks,
On Sun, Feb 05, 2023 at 10:18:30PM -0500, Peter Xu wrote: > On Mon, Feb 06, 2023 at 02:51:18AM +0000, Matthew Wilcox wrote: > > That wasn't what I meant. I meant putting VM_FAULT_BADMAP and > > VM_FAULT_SIGSEGV in mm_types.h. Not having "Here is a range of reserved > > arch private ones". > > VM_FAULT_SIGSEGV is there already; I assume you meant adding them all > directly into vm_fault_reason. > > Then I don't think it's a good idea.. > > Currently vm_fault_reason is a clear interface for handle_mm_fault() for > not only arch pffault handlers but also soft faults like GUP. > > If handle_mm_fault() doesn't return VM_FAULT_BADMAP at all, I don't think > we should have it as public API at all. When arch1 people reading the > VM_FAULT_ documents, it shouldn't care about some fault reason that only > happens with arch2. Gup shouldn't care about it either. > > Logically a new page fault handler should handle all the retval of > vm_fault_reason afaiu. That shouldn't include e.g. VM_FAULT_BADMAP either. Hmm, right. Looking specifically at how s390 uses VM_FAULT_BADMAP, it just seems to be a badly structured fault.c. Seems to me that do_fault_error() should take an extra si_code argument, and instead of returning VM_FAULT_BADACCESS / VM_FAULT_BADMAP from various functions, those functions should call do_fault_error() directly, passing it VM_FAULT_SIGSEGV and the appropriate si_code. But this is all on the s390 people to fix; I don't want to break their arch by trying it myself.
On Mon, Feb 06, 2023 at 05:09:57AM +0000, Matthew Wilcox wrote: > On Sun, Feb 05, 2023 at 10:18:30PM -0500, Peter Xu wrote: > > On Mon, Feb 06, 2023 at 02:51:18AM +0000, Matthew Wilcox wrote: > > > That wasn't what I meant. I meant putting VM_FAULT_BADMAP and > > > VM_FAULT_SIGSEGV in mm_types.h. Not having "Here is a range of reserved > > > arch private ones". > > > > VM_FAULT_SIGSEGV is there already; I assume you meant adding them all > > directly into vm_fault_reason. > > > > Then I don't think it's a good idea.. > > > > Currently vm_fault_reason is a clear interface for handle_mm_fault() for > > not only arch pffault handlers but also soft faults like GUP. > > > > If handle_mm_fault() doesn't return VM_FAULT_BADMAP at all, I don't think > > we should have it as public API at all. When arch1 people reading the > > VM_FAULT_ documents, it shouldn't care about some fault reason that only > > happens with arch2. Gup shouldn't care about it either. > > > > Logically a new page fault handler should handle all the retval of > > vm_fault_reason afaiu. That shouldn't include e.g. VM_FAULT_BADMAP either. > > Hmm, right. Looking specifically at how s390 uses VM_FAULT_BADMAP, > it just seems to be a badly structured fault.c. Seems to me that > do_fault_error() should take an extra si_code argument, and > instead of returning VM_FAULT_BADACCESS / VM_FAULT_BADMAP from > various functions, those functions should call do_fault_error() > directly, passing it VM_FAULT_SIGSEGV and the appropriate si_code. > > But this is all on the s390 people to fix; I don't want to break their > arch by trying it myself. Yes, will take a look at it. For now I will apply Peter's patch in order to get rid of the collision.