Message ID | 20230515090848.833045-7-bhe@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6778111vqo; Mon, 15 May 2023 02:16:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7HHbnBDW3NAqS5/ZIi5BoRd/xVyx9Bzf3wq0luDKh5Vx3IC57HTZtar8mNnxD5Fo+MpJoi X-Received: by 2002:a05:6a20:3c88:b0:103:8c8b:c689 with SMTP id b8-20020a056a203c8800b001038c8bc689mr20487914pzj.51.1684142179191; Mon, 15 May 2023 02:16:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684142179; cv=none; d=google.com; s=arc-20160816; b=l8DHHW7HlYBDRGFBz+NYV1LWz60NmGxLVvoMkH/1SdIiQV9lZ99aehcOMNWzHUeb3p x7bV94JX5YbMI9vp/hHn0wspSm45QbDCxrd2p9/XiVL9LS2aFCBQKnPQzkCkzumggnnU zp/ad9CsNcisIiY5v6RpsmO4FUPZ0K0FEPOXuXht8No6ofLXgFl1bVVgyIZLnAFBGrmy ED1dKQo1IdycC41MssI0Pom4IuQJk9FBPlOzIwiDFzHifDERuklb67ft9ddnQvhQniYc sodsRQE6G/gfKq/ulF6wQvsufCKkXffIc347AjXm4flwe36ZqmVpJ5ZJdO3GvSLySbqQ vmWA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b04gx2CEsZva7MKdHssokOo8Q5KwYfP6QKwltziak5c=; b=yir5hTQTiNE8BbH/Y/BaxCZvxcBdbVHbBZ7vHi/hr2RjAzwNbWWgZn55npexFezItO zQs+8WmTFLwD14rYc0U8baQc0r8jtyJHoPmUKoGd127Mn1rxepnyB+MsoMXIbAgofIHU zcb/9IxkYsR/Ijb5F2URz63XY9shW7K62qwqJkfzdsaw2ZCOJAXOEp/nMpqvJuTMgvzr Ujm1zzHl3HFIo8H0BDtvVVFGF7gjOLh2H/w3NQN5EWSgnYNXleL7yazivbYpBABpM1WS rgeAtBi5hK1thRq3nId3KjHj/B4Zpe8ZlFLBffLBXjelkxdCjWh2FkrBHYVoMc6tLBGA 0bEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AdeXtHno; 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 g130-20020a636b88000000b005138de75d17si15257103pgc.116.2023.05.15.02.16.06; Mon, 15 May 2023 02:16:19 -0700 (PDT) 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=AdeXtHno; 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 S239895AbjEOJLA (ORCPT <rfc822;peekingduck44@gmail.com> + 99 others); Mon, 15 May 2023 05:11:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbjEOJKb (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 15 May 2023 05:10:31 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBCA010C2 for <linux-kernel@vger.kernel.org>; Mon, 15 May 2023 02:09:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684141793; 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: in-reply-to:in-reply-to:references:references; bh=b04gx2CEsZva7MKdHssokOo8Q5KwYfP6QKwltziak5c=; b=AdeXtHnoQxzJJAPLT88E0F/P5WsQJmLdiCPF7XHWsy+wrnmnc1jgBRk9ppiaSe+gNfDZbU lBbHtKWasEeqCu4mIEkoK1oGZM0aTDf/PunQXWxirNzgtGj607bY2od1Y4nKCtO/pss1hR 4i8AfiTeTKp4vtxhBIGU123jzr8Qw6U= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-pgJ34I4-N4Gq1USkcYQgAg-1; Mon, 15 May 2023 05:09:46 -0400 X-MC-Unique: pgJ34I4-N4Gq1USkcYQgAg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C4503C0CEFD; Mon, 15 May 2023 09:09:46 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-32.pek2.redhat.com [10.72.12.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FFEC40C2063; Mon, 15 May 2023 09:09:39 +0000 (UTC) From: Baoquan He <bhe@redhat.com> To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, willy@infradead.org, deller@gmx.de, Baoquan He <bhe@redhat.com> Subject: [PATCH v5 RESEND 06/17] mm/ioremap: add slab availability checking in ioremap_prot Date: Mon, 15 May 2023 17:08:37 +0800 Message-Id: <20230515090848.833045-7-bhe@redhat.com> In-Reply-To: <20230515090848.833045-1-bhe@redhat.com> References: <20230515090848.833045-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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?1765951069470005845?= X-GMAIL-MSGID: =?utf-8?q?1765951069470005845?= |
Series |
mm: ioremap: Convert architectures to take GENERIC_IOREMAP way
|
|
Commit Message
Baoquan He
May 15, 2023, 9:08 a.m. UTC
Several architectures has done checking if slab if available in
ioremap_prot(). In fact it should be done in generic ioremap_prot()
since on any architecutre, slab allocator must be available before
get_vm_area_caller() and vunmap() are used.
Add the checking into generic_ioremap_prot().
Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Baoquan He <bhe@redhat.com>
---
mm/ioremap.c | 4 ++++
1 file changed, 4 insertions(+)
Comments
On Mon, May 15, 2023 at 05:08:37PM +0800, Baoquan He wrote: > Several architectures has done checking if slab if available in > ioremap_prot(). In fact it should be done in generic ioremap_prot() > since on any architecutre, slab allocator must be available before > get_vm_area_caller() and vunmap() are used. > > Add the checking into generic_ioremap_prot(). > > Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu> > Signed-off-by: Baoquan He <bhe@redhat.com> Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org> > --- > mm/ioremap.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/mm/ioremap.c b/mm/ioremap.c > index 9f34a8f90b58..2fbe6b9bc50e 100644 > --- a/mm/ioremap.c > +++ b/mm/ioremap.c > @@ -18,6 +18,10 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, > phys_addr_t last_addr; > struct vm_struct *area; > > + /* An early platform driver might end up here */ > + if (!slab_is_available()) > + return NULL; > + > /* Disallow wrap-around or zero size */ > last_addr = phys_addr + size - 1; > if (!size || last_addr < phys_addr) > -- > 2.34.1 > >
On Mon, May 15, 2023 at 05:08:37PM +0800, Baoquan He wrote: > Several architectures has done checking if slab if available in > ioremap_prot(). In fact it should be done in generic ioremap_prot() > since on any architecutre, slab allocator must be available before > get_vm_area_caller() and vunmap() are used. > > Add the checking into generic_ioremap_prot(). Should we add a WARN_ON/WARN_ON_ONCE to aid debugging? Otherwise looks good: Reviewed-by: Christoph Hellwig <hch@lst.de>
On 05/16/23 at 11:30pm, Christoph Hellwig wrote: > On Mon, May 15, 2023 at 05:08:37PM +0800, Baoquan He wrote: > > Several architectures has done checking if slab if available in > > ioremap_prot(). In fact it should be done in generic ioremap_prot() > > since on any architecutre, slab allocator must be available before > > get_vm_area_caller() and vunmap() are used. > > > > Add the checking into generic_ioremap_prot(). > > Should we add a WARN_ON/WARN_ON_ONCE to aid debugging? Sounds like a great idea, will add WARN_ON_ONCE as below. Thanks. if (WARN_ON_ONCE(!slab_is_available())) return NULL;
diff --git a/mm/ioremap.c b/mm/ioremap.c index 9f34a8f90b58..2fbe6b9bc50e 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -18,6 +18,10 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr_t last_addr; struct vm_struct *area; + /* An early platform driver might end up here */ + if (!slab_is_available()) + return NULL; + /* Disallow wrap-around or zero size */ last_addr = phys_addr + size - 1; if (!size || last_addr < phys_addr)