linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Wenhu Wang <wenhu.wang@hotmail.com>,
	Greg KH <gregkh@linuxfoundation.org>
Cc: "mpe@ellerman.id.au" <mpe@ellerman.id.au>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] uio:powerpc:mpc85xx: l2-cache-sram uio driver implementation
Date: Tue, 14 Jun 2022 14:59:55 +0000	[thread overview]
Message-ID: <99646595-d09a-e49e-d0b2-c2a317b19d09@csgroup.eu> (raw)
In-Reply-To: <SG2PR01MB2951CE54262F791931F4AAE19FAA9@SG2PR01MB2951.apcprd01.prod.exchangelabs.com>



Le 14/06/2022 à 16:40, Wenhu Wang a écrit :
>>>>
>>>> I looked at that patch.
>>>>
>>>> I don't think you can just drop the #ifdef in function
>>>> __access_remote_vm() in mm/memory.c
>>>>
>>>> You have to replace it with something like:
>>>>
>>>>        if (!IS_ENABLED(CONFIG_HAVE_IOREMAP_PROT))
>>>>            break;
>>>>
>>>
>>>
>>> Another thing in that patch:
>>>
>>> By making generic_access_phys() a static inline, it means that everytime
>>> you refer to the address of that function in a vm_operations_struct
>>> struct, the compiler has to provide an outlined instance of the
>>> function. It means you'll likely have several instances of a
>>> generic_access_phys().
>>>
>>> What you could do instead is to add the following at the start of
>>> generic_access_phys() in mm/memory.c :
>>>
>>>          if (!IS_ENABLED(CONFIG_HAVE_IOREMAP_PROT))
>>>                  return 0;
>>>
>>
>> It is really a better chmoce, thanks for the advice.
>> Multiple instances exist as you mentioned, the block returns 0 with no-op
>> instance which makes no difference with the function return value.
>>
>> I will update the patch after a re-confirming.
>>
> 
> I tried as adviced but when not defined, error happens on archectures such
> as arm64. Actually the function generic_access_phys calls a lot of functions
> that become undefined if we compile it with CONFIG_HAVE_IOREMAP_PROT disabled.
> The archectures that support CONFIG_HAVE_IOREMAP_PROT are mips, x86, sh, arc,
> s390, loongarch and powerpc.
> 
> So we may just define the function with static inline and add IS_ENABLED
> condition branch in function __access_remote_vm in mm/memory.c. The executing
> path breaks if CONFIG_HAVE_IOREMAP_PROT is disabled, and never goes into the
> static no-op function.
> 
> In short, the static inline no-op function would never be executed, the only
> difference is that there would be a lot of function code in compiled target.
> 

In that case all you have to do is:

diff --git a/mm/memory.c b/mm/memory.c
index 7a089145cad4..39b369fc77f6 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -5413,6 +5413,13 @@ int generic_access_phys(struct vm_area_struct 
*vma, unsigned long addr,
  	return ret;
  }
  EXPORT_SYMBOL_GPL(generic_access_phys);
+#else
+int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
+			void *buf, int len, int write)
+{
+	return 0;
+}
+EXPORT_SYMBOL_GPL(generic_access_phys);
  #endif

  /*


Christophe

  reply	other threads:[~2022-06-14 15:00 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220609102855.272270-1-wenhu.wang@hotmail.com>
2022-06-09 10:28 ` [PATCH 1/2] powerpc:mm: export symbol ioremap_coherent Wang Wenhu
2022-06-14 10:45   ` Michael Ellerman
2022-06-14 14:49     ` Christoph Hellwig
2022-06-15  4:37     ` 回复: " Wenhu Wang
2022-06-09 10:28 ` [PATCH 2/2] uio:powerpc:mpc85xx: l2-cache-sram uio driver implementation Wang Wenhu
2022-06-09 13:17   ` Greg KH
2022-06-14  6:09     ` 回复: " Wenhu Wang
2022-06-14  6:34       ` Greg KH
2022-06-14  7:12         ` Christophe Leroy
2022-06-14  7:18       ` Christophe Leroy
2022-06-14  7:26         ` Christophe Leroy
2022-06-14  7:53           ` Wenhu Wang
2022-06-14  8:03             ` Greg KH
2022-06-14  8:39               ` Wenhu Wang
2022-06-14 14:40             ` Wenhu Wang
2022-06-14 14:59               ` Christophe Leroy [this message]
2022-06-15  6:04       ` 回复: " Christophe Leroy
2022-06-15  5:57     ` [PATCHv2 0/2] uio:powerpc:mpc85xx: l2-cache-sram uio driver Wang Wenhu
     [not found]     ` <20220615055735.53585-1-wenhu.wang@hotmail.com>
2022-06-15  5:57       ` [PATCHv2 1/2] mm: eliminate ifdef of HAVE_IOREMAP_PROT in .c files Wang Wenhu
2022-06-15  6:49         ` Christoph Hellwig
2022-06-22  2:22         ` kernel test robot
2022-06-22  4:13         ` kernel test robot
2022-06-15  5:57       ` [PATCHv2 2/2] uio:powerpc:mpc85xx: l2-cache-sram uio driver implementation Wang Wenhu
2022-06-15  6:43         ` Christoph Hellwig
2022-06-15  6:48         ` Christophe Leroy
2022-06-15  6:49         ` Christophe Leroy
2022-06-14 14:51   ` [PATCH " Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=99646595-d09a-e49e-d0b2-c2a317b19d09@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=wenhu.wang@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).