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 X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85B3CC43461 for ; Tue, 1 Sep 2020 06:49:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3B9AA208DB for ; Tue, 1 Sep 2020 06:49:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="JZ1I6hjv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B9AA208DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A24D26B0003; Tue, 1 Sep 2020 02:49:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D7396B0037; Tue, 1 Sep 2020 02:49:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8ECA76B005D; Tue, 1 Sep 2020 02:49:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0047.hostedemail.com [216.40.44.47]) by kanga.kvack.org (Postfix) with ESMTP id 78E5C6B0003 for ; Tue, 1 Sep 2020 02:49:50 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 316C5181AEF10 for ; Tue, 1 Sep 2020 06:49:50 +0000 (UTC) X-FDA: 77213567340.01.bulb74_600efc827096 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id E958010047E2B for ; Tue, 1 Sep 2020 06:49:49 +0000 (UTC) X-HE-Tag: bulb74_600efc827096 X-Filterd-Recvd-Size: 6588 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Tue, 1 Sep 2020 06:49:49 +0000 (UTC) Received: from kernel.org (unknown [87.70.91.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6E479208DB; Tue, 1 Sep 2020 06:49:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598942988; bh=NvCekPHIZCmnbkeS6yKm6q1qga5DpGl3Zr7rAiRiOHo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JZ1I6hjvaQ67DJfPskMNXjYHEDuqWjex2aZC8Zfyxjmj/mq/nE8TOuA8Dhh+w3rxw ogOuBGdv3DJ4rSGgL8qcm5KYEpf5hTQCgN9UqbE9icLxSbAs7a/lp74v/M1LnsdKwh vtKGLgt0ovSk6VsSz2SfdluksPtSSjR0rBMspnUQ= Date: Tue, 1 Sep 2020 09:49:42 +0300 From: Mike Rapoport To: Nicholas Piggin Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Arnd Bergmann Subject: Re: [PATCH v2 01/23] asm-generic: add generic MMU versions of mmu context functions Message-ID: <20200901064942.GD432455@kernel.org> References: <20200826145249.745432-1-npiggin@gmail.com> <20200826145249.745432-2-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200826145249.745432-2-npiggin@gmail.com> X-Rspamd-Queue-Id: E958010047E2B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: On Thu, Aug 27, 2020 at 12:52:27AM +1000, Nicholas Piggin wrote: > Many of these are no-ops on many architectures, so extend mmu_context.h > to cover MMU and NOMMU, and split the NOMMU bits out to nommu_context.h > > Cc: Arnd Bergmann > Cc: linux-arch@vger.kernel.org > Signed-off-by: Nicholas Piggin > --- > arch/microblaze/include/asm/mmu_context.h | 2 +- > arch/sh/include/asm/mmu_context.h | 2 +- > include/asm-generic/mmu_context.h | 57 +++++++++++++++++------ > include/asm-generic/nommu_context.h | 19 ++++++++ > 4 files changed, 64 insertions(+), 16 deletions(-) > create mode 100644 include/asm-generic/nommu_context.h > > diff --git a/arch/microblaze/include/asm/mmu_context.h b/arch/microblaze/include/asm/mmu_context.h > index f74f9da07fdc..34004efb3def 100644 > --- a/arch/microblaze/include/asm/mmu_context.h > +++ b/arch/microblaze/include/asm/mmu_context.h > @@ -2,5 +2,5 @@ > #ifdef CONFIG_MMU > # include > #else > -# include > +# include > #endif > diff --git a/arch/sh/include/asm/mmu_context.h b/arch/sh/include/asm/mmu_context.h > index f664e51e8a15..461b1304580b 100644 > --- a/arch/sh/include/asm/mmu_context.h > +++ b/arch/sh/include/asm/mmu_context.h > @@ -133,7 +133,7 @@ static inline void switch_mm(struct mm_struct *prev, > #define set_TTB(pgd) do { } while (0) > #define get_TTB() (0) > > -#include > +#include > > #endif /* CONFIG_MMU */ > > diff --git a/include/asm-generic/mmu_context.h b/include/asm-generic/mmu_context.h > index 6be9106fb6fb..86cea80a50df 100644 > --- a/include/asm-generic/mmu_context.h > +++ b/include/asm-generic/mmu_context.h > @@ -3,44 +3,73 @@ > #define __ASM_GENERIC_MMU_CONTEXT_H > > /* > - * Generic hooks for NOMMU architectures, which do not need to do > - * anything special here. > + * Generic hooks to implement no-op functionality. > */ > > -#include > - > struct task_struct; > struct mm_struct; > > +/* > + * enter_lazy_tlb - Called when "tsk" is about to enter lazy TLB mode. > + * > + * @mm: the currently active mm context which is becoming lazy > + * @tsk: task which is entering lazy tlb > + * > + * tsk->mm will be NULL > + */ > +#ifndef enter_lazy_tlb > static inline void enter_lazy_tlb(struct mm_struct *mm, > struct task_struct *tsk) > { > } > +#endif > > +/** > + * init_new_context - Initialize context of a new mm_struct. > + * @tsk: task struct for the mm > + * @mm: the new mm struct 'make *docs' will complain here about missing Return: description > + */ > +#ifndef init_new_context > static inline int init_new_context(struct task_struct *tsk, > struct mm_struct *mm) > { > return 0; > } > +#endif Most architectures have non-trivial init_new_context, maybe this should go into nommu_context.h? > +/** > + * destroy_context - Undo init_new_context when the mm is going away > + * @mm: old mm struct > + */ > +#ifndef destroy_context > static inline void destroy_context(struct mm_struct *mm) > { > } > +#endif > > -static inline void deactivate_mm(struct task_struct *task, > - struct mm_struct *mm) > -{ > -} > - > -static inline void switch_mm(struct mm_struct *prev, > - struct mm_struct *next, > - struct task_struct *tsk) > +/** > + * activate_mm - called after exec switches the current task to a new mm, to switch to it > + * @prev_mm: previous mm of this task > + * @next_mm: new mm > + */ > +#ifndef activate_mm > +static inline void activate_mm(struct mm_struct *prev_mm, > + struct mm_struct *next_mm) > { > + switch_mm(prev_mm, next_mm, current); > } > +#endif > > -static inline void activate_mm(struct mm_struct *prev_mm, > - struct mm_struct *next_mm) > +/** > + * dectivate_mm - called when an mm is released after exit or exec switches away from it > + * @tsk: the task > + * @mm: the old mm > + */ > +#ifndef deactivate_mm > +static inline void deactivate_mm(struct task_struct *tsk, > + struct mm_struct *mm) > { > } > +#endif > > #endif /* __ASM_GENERIC_MMU_CONTEXT_H */ > diff --git a/include/asm-generic/nommu_context.h b/include/asm-generic/nommu_context.h > new file mode 100644 > index 000000000000..4f916f9e16cd > --- /dev/null > +++ b/include/asm-generic/nommu_context.h > @@ -0,0 +1,19 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef __ASM_GENERIC_NOMMU_H > +#define __ASM_GENERIC_NOMMU_H > + > +/* > + * Generic hooks for NOMMU architectures, which do not need to do > + * anything special here. > + */ > +#include > + > +static inline void switch_mm(struct mm_struct *prev, > + struct mm_struct *next, > + struct task_struct *tsk) > +{ > +} > + > +#include > + > +#endif /* __ASM_GENERIC_NOMMU_H */ > -- > 2.23.0 > > -- Sincerely yours, Mike.