kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC v1] nfs/write: Use common error handling code in nfs_lock_and_join_requests()
@ 2017-11-07 16:53 SF Markus Elfring
  2017-12-03 14:15 ` Difficulties for compilation without extra optimisation SF Markus Elfring
  0 siblings, 1 reply; 10+ messages in thread
From: SF Markus Elfring @ 2017-11-07 16:53 UTC (permalink / raw)
  To: linux-nfs, Anna Schumaker, Trond Myklebust; +Cc: LKML, kernel-janitors

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 3201 bytes --]

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Nov 2017 08:51:00 +0100

Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v1 - Request for comments:
I can offer another bit of information for a software development discussion. 💭

The affected source file can be compiled for the processor architecture “x86_64”
by a tool like “GCC 6.4.1+r251631-1.3” from the software distribution
“openSUSE Tumbleweed” with the following command example.

my_cc=/usr/bin/gcc-6 \
&& my_module=fs/nfs/write.o \
&& for XYZ in 0 s 3; do echo "   _____ $XYZ _____" \
&& my_extra="-O$XYZ" \
&& git checkout next-20171102 \
&& make -j4 CC="${my_cc}" HOSTCC="${my_cc}" EXTRA_CFLAGS="${my_extra}" allmodconfig "${my_module}" \
&& size "${my_module}" \
&& git checkout ':/^nfs/write: Use common error handling code in nfs_lock_and_join_requests' \
&& make -j4 CC="${my_cc}" HOSTCC="${my_cc}" EXTRA_CFLAGS="${my_extra}" allmodconfig "${my_module}" \
&& size "${my_module}"; done


🔮 Do you find the following differences worth for further clarification?

╔═════════╤══════╗
║ setting │ text ║
╠═════════╪══════╣
║   O0    │ ???  ║   Compilation failure?
║   Os    │ -17  ║
║   O3    │ -16  ║
╚═════════╧══════╝


 fs/nfs/write.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index babebbccae2a..5b5f464f6f2a 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -487,10 +487,8 @@ nfs_lock_and_join_requests(struct page *page)
 	}
 
 	ret = nfs_page_group_lock(head);
-	if (ret < 0) {
-		nfs_unlock_and_release_request(head);
-		return ERR_PTR(ret);
-	}
+	if (ret < 0)
+		goto release_request;
 
 	/* lock each request in the page group */
 	total_bytes = head->wb_bytes;
@@ -515,8 +513,7 @@ nfs_lock_and_join_requests(struct page *page)
 			if (ret < 0) {
 				nfs_unroll_locks(inode, head, subreq);
 				nfs_release_request(subreq);
-				nfs_unlock_and_release_request(head);
-				return ERR_PTR(ret);
+				goto release_request;
 			}
 		}
 		/*
@@ -532,8 +529,8 @@ nfs_lock_and_join_requests(struct page *page)
 			nfs_page_group_unlock(head);
 			nfs_unroll_locks(inode, head, subreq);
 			nfs_unlock_and_release_request(subreq);
-			nfs_unlock_and_release_request(head);
-			return ERR_PTR(-EIO);
+			ret = -EIO;
+			goto release_request;
 		}
 	}
 
@@ -576,6 +573,10 @@ nfs_lock_and_join_requests(struct page *page)
 	/* still holds ref on head from nfs_page_find_head_request
 	 * and still has lock on head from lock loop */
 	return head;
+
+release_request:
+	nfs_unlock_and_release_request(head);
+	return ERR_PTR(ret);
 }
 
 static void nfs_write_error_remove_page(struct nfs_page *req)
-- 
2.15.0

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Difficulties for compilation without extra optimisation
  2017-11-07 16:53 [PATCH RFC v1] nfs/write: Use common error handling code in nfs_lock_and_join_requests() SF Markus Elfring
@ 2017-12-03 14:15 ` SF Markus Elfring
  2017-12-03 15:17   ` Trond Myklebust
  0 siblings, 1 reply; 10+ messages in thread
From: SF Markus Elfring @ 2017-12-03 14:15 UTC (permalink / raw)
  To: kernel-janitors

Hello,

I came along some software modules where I suggested source code adjustments.

Example:
nfs/write: Use common error handling code in nfs_lock_and_join_requests()

https://lkml.org/lkml/2017/11/7/599
https://patchwork.kernel.org/patch/10047013/
https://lkml.kernel.org/r/<7f072f78-eef4-6d87-d233-cee71dac5a32@users.sourceforge.net>

I would like to check corresponding build results then without extra
optimisation applied by the compiler.
But I got surprised by error messages for a command like the following.

elfring@Sonne:~/Projekte/Linux/next-patched> my_cc=/usr/bin/gcc-7 && LANG=C make -j4 CC="${my_cc}" HOSTCC="${my_cc}" EXTRA_CFLAGS='-O0' allmodconfig fs/nfs/write.o
…
In file included from ./include/linux/compiler.h:58:0,
                 from ./include/uapi/linux/stddef.h:1,
                 from ./include/linux/stddef.h:4,
                 from ./include/uapi/linux/posix_types.h:4,
                 from ./include/uapi/linux/types.h:13,
                 from ./include/linux/types.h:5,
                 from fs/nfs/write.c:9:
./arch/x86/include/asm/jump_label.h: In function ‘trace_nfs_writeback_page_enter’:
./include/linux/compiler-gcc.h:275:38: warning: asm operand 0 probably doesn’t match constraints
 #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
…


How do you think about to improve this software situation anyhow?

Regards,
Markus

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Difficulties for compilation without extra optimisation
  2017-12-03 14:15 ` Difficulties for compilation without extra optimisation SF Markus Elfring
@ 2017-12-03 15:17   ` Trond Myklebust
  2017-12-03 21:22     ` Steven Rostedt
  0 siblings, 1 reply; 10+ messages in thread
From: Trond Myklebust @ 2017-12-03 15:17 UTC (permalink / raw)
  To: kernel-janitors

T24gU3VuLCAyMDE3LTEyLTAzIGF0IDE1OjE1ICswMTAwLCBTRiBNYXJrdXMgRWxmcmluZyB3cm90
ZToNCj4gSGVsbG8sDQo+IA0KPiBJIGNhbWUgYWxvbmcgc29tZSBzb2Z0d2FyZSBtb2R1bGVzIHdo
ZXJlIEkgc3VnZ2VzdGVkIHNvdXJjZSBjb2RlDQo+IGFkanVzdG1lbnRzL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9sYWJlbC5oLg0KDQpDY2luZyBQZXRlciBa
aWpsc3RyYSAod2hvIGFwcGVhcnMgdG8gaGF2ZSBiZWVuIHRoZSBsYXN0IHBlcnNvbiB0byB0b3Vj
aA0KdGhhdCBhc3NlbWJseSBjb2RlKSBhbmQgU3RldmVuIFJvc3RlZHQuDQoNCi0tIA0KVHJvbmQg
TXlrbGVidXN0DQpMaW51eCBORlMgY2xpZW50IG1haW50YWluZXIsIFByaW1hcnlEYXRhDQp0cm9u
ZC5teWtsZWJ1c3RAcHJpbWFyeWRhdGEuY29tDQo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Difficulties for compilation without extra optimisation
  2017-12-03 15:17   ` Trond Myklebust
@ 2017-12-03 21:22     ` Steven Rostedt
  2017-12-03 21:56       ` SF Markus Elfring
  2017-12-04  9:00       ` SF Markus Elfring
  0 siblings, 2 replies; 10+ messages in thread
From: Steven Rostedt @ 2017-12-03 21:22 UTC (permalink / raw)
  To: kernel-janitors

On Sun, 3 Dec 2017 15:17:32 +0000
Trond Myklebust <trondmy@primarydata.com> wrote:

> > I would like to check corresponding build results then without extra
> > optimisation applied by the compiler.
> > But I got surprised by error messages for a command like the
> > following.
> > 
> > elfring@Sonne:~/Projekte/Linux/next-patched> my_cc=/usr/bin/gcc-7 &&
> > LANG=C make -j4 CC="${my_cc}" HOSTCC="${my_cc}" EXTRA_CFLAGS='-O0'
> > allmodconfig fs/nfs/write.o

Why would you compile the kernel without optimization? There's many
places in the kernel that WILL NOT BUILD without optimization. In fact,
we do a lot of tricks to make sure that things work the way we expect
it to, because we add broken code that only gets compiled out when gcc
optimizes the code the way we expect it to be, and the kernel build
will break otherwise.

-- Steve

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Difficulties for compilation without extra optimisation
  2017-12-03 21:22     ` Steven Rostedt
@ 2017-12-03 21:56       ` SF Markus Elfring
  2017-12-04  2:40         ` Steven Rostedt
  2017-12-04  9:00       ` SF Markus Elfring
  1 sibling, 1 reply; 10+ messages in thread
From: SF Markus Elfring @ 2017-12-03 21:56 UTC (permalink / raw)
  To: kernel-janitors

> Why would you compile the kernel without optimization?

I would like to see how big an effect finally is in such a build configuration
after specific source code adjustments.


> There's many places in the kernel that WILL NOT BUILD without optimization.

I did not really know this detail so far.

I noticed that the optimised build variants worked during my test comparisons.


> In fact, we do a lot of tricks to make sure that things work the way
> we expect it to, because we add broken code that only gets compiled out
> when gcc optimizes the code the way we expect it to be,
> and the kernel build will break otherwise.

Thanks for your information.

Can the software areas distinguished where such special handling matters?

Regards,
Markus

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Difficulties for compilation without extra optimisation
  2017-12-03 21:56       ` SF Markus Elfring
@ 2017-12-04  2:40         ` Steven Rostedt
  2017-12-04  9:55           ` SF Markus Elfring
  0 siblings, 1 reply; 10+ messages in thread
From: Steven Rostedt @ 2017-12-04  2:40 UTC (permalink / raw)
  To: kernel-janitors

On Sun, 3 Dec 2017 22:56:51 +0100
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> Can the software areas distinguished where such special handling matters?

No idea. That's something you are going to have to figure out on your
own.

-- Steve

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Difficulties for compilation without extra optimisation
  2017-12-03 21:22     ` Steven Rostedt
  2017-12-03 21:56       ` SF Markus Elfring
@ 2017-12-04  9:00       ` SF Markus Elfring
  2017-12-04  9:48         ` Steven Rostedt
  1 sibling, 1 reply; 10+ messages in thread
From: SF Markus Elfring @ 2017-12-04  9:00 UTC (permalink / raw)
  To: kernel-janitors

> Why would you compile the kernel without optimization?

Can another reason be occasionally still relevant?

Will the compilation be a bit quicker when extra data processing
could be omitted?


> There's many places in the kernel that WILL NOT BUILD without optimization.

Would you like to keep the software situation in this way?


> In fact, we do a lot of tricks to make sure that things work the way
> we expect it to, because we add broken code that only gets compiled out
> when gcc optimizes the code the way we expect it to be,
> and the kernel build will break otherwise.

* Can this goal be also achieved without the addition of “broken code”?

* How do you think about to improve the error handling there?

Regards,
Markus

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Difficulties for compilation without extra optimisation
  2017-12-04  9:00       ` SF Markus Elfring
@ 2017-12-04  9:48         ` Steven Rostedt
  2017-12-04 10:18           ` SF Markus Elfring
  0 siblings, 1 reply; 10+ messages in thread
From: Steven Rostedt @ 2017-12-04  9:48 UTC (permalink / raw)
  To: kernel-janitors

On Mon, 4 Dec 2017 10:00:54 +0100
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> > Why would you compile the kernel without optimization?  
> 
> Can another reason be occasionally still relevant?

No.

> 
> Will the compilation be a bit quicker when extra data processing
> could be omitted?

Why would you care more about the time it takes to compile the kernel,
than the time it takes for executing it? Benchmarks are all about
performance of a running kernel, nobody compares benchmarks of the time
it takes to compile it. Sure, we like to make the compile times quicker
(heck, I wrote "make localmodconfig" for just that purpose), but we
never favor compiler time over execution time. In fact, if we can
improve the execution performance by sacrificing compile time, we are
happy to do that.

> 
> 
> > There's many places in the kernel that WILL NOT BUILD without optimization.  
> 
> Would you like to keep the software situation in this way?

Yes.

> 
> 
> > In fact, we do a lot of tricks to make sure that things work the way
> > we expect it to, because we add broken code that only gets compiled out
> > when gcc optimizes the code the way we expect it to be,
> > and the kernel build will break otherwise.  
> 
> * Can this goal be also achieved without the addition of “broken code”?

No.

> 
> * How do you think about to improve the error handling there?

It works just fine as is. Errors that can be detected at build time are
100 times better than detecting them at execution time.

-- Steve

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Difficulties for compilation without extra optimisation
  2017-12-04  2:40         ` Steven Rostedt
@ 2017-12-04  9:55           ` SF Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2017-12-04  9:55 UTC (permalink / raw)
  To: kernel-janitors

>> Can the software areas distinguished where such special handling matters?
> 
> No idea.

I would like to point another example out.


> That's something you are going to have to figure out on your own.

How do you think about information from an other clarification request
for the topic “caif: Use common error handling code in cfdgml_receive()”?

https://lkml.org/lkml/2017/11/7/486
https://patchwork.kernel.org/patch/10046849/
https://lkml.kernel.org/r/<034c0760-b8af-0fe2-e7a0-81199ff31931@users.sourceforge.net>

Regards,
Markus

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Difficulties for compilation without extra optimisation
  2017-12-04  9:48         ` Steven Rostedt
@ 2017-12-04 10:18           ` SF Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2017-12-04 10:18 UTC (permalink / raw)
  To: kernel-janitors

>> Will the compilation be a bit quicker when extra data processing
>> could be omitted?
> 
> Why would you care more about the time it takes to compile the kernel,
> than the time it takes for executing it?

I am also interested in the evolution of compilation time frames.


> Benchmarks are all about performance of a running kernel,

This is generally reasonable.


> nobody compares benchmarks of the time it takes to compile it.

I guess that the situation can be occasionally different there.


> Sure, we like to make the compile times quicker

Good to know …


> (heck, I wrote "make localmodconfig" for just that purpose),

Thanks.


> but we never favor compiler time over execution time.

I imagine that the speed expectations could be adjusted during software development,
couldn't they?


> In fact, if we can improve the execution performance by sacrificing compile time,
> we are happy to do that.

I guess that you would like to consider some constraints there.


>>> In fact, we do a lot of tricks to make sure that things work the way
>>> we expect it to, because we add broken code that only gets compiled out
>>> when gcc optimizes the code the way we expect it to be,
>>> and the kernel build will break otherwise.  
>>
>> * Can this goal be also achieved without the addition of “broken code”?
> 
> No.

Will any other contributors take another look?


>> * How do you think about to improve the error handling there?
> 
> It works just fine as is.

I hope that further software improvements can be achieved also for this use case.


> Errors that can be detected at build time are 100 times better
> than detecting them at execution time.

I agree to such a general view.

Will an other (or no) error message be more appropriate?

Regards,
Markus

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-12-04 10:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-07 16:53 [PATCH RFC v1] nfs/write: Use common error handling code in nfs_lock_and_join_requests() SF Markus Elfring
2017-12-03 14:15 ` Difficulties for compilation without extra optimisation SF Markus Elfring
2017-12-03 15:17   ` Trond Myklebust
2017-12-03 21:22     ` Steven Rostedt
2017-12-03 21:56       ` SF Markus Elfring
2017-12-04  2:40         ` Steven Rostedt
2017-12-04  9:55           ` SF Markus Elfring
2017-12-04  9:00       ` SF Markus Elfring
2017-12-04  9:48         ` Steven Rostedt
2017-12-04 10:18           ` SF Markus Elfring

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).