From ozyalpy at gmail.com Thu Feb 1 17:33:30 2018 From: ozyalpy at gmail.com (Ozan Alpay) Date: Thu, 1 Feb 2018 18:33:30 +0100 (CET) Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 Message-ID: Dear Rodrigo Vivi, Ville Syrj?l?, My name is Ozan Alpay, and I am a student mentored by Lukas Bulwahn. We intend to use static analysis tools on the kernel source to identify, analyze and report issues. As a very first step, we are looking into clang compiler warnings and will then move to more sophisticated tools. When compiling Linux 4.15 with clang, we have discovered that your commit 2952cd6fb4cc ("drm/i915: Let's use more enum intel_dpll_id pll_id.") introduced the following warning: drivers/gpu/drm/i915/intel_ddi.c:1481:30: warning: implicit conversion from enumeration type 'enum port' to different enumeration type 'enum intel_dpll_id' [-Wenum-conversion] enum intel_dpll_id pll_id = port; To reproduce it, you can compile Linux 4.15 with clang with this command: make HOSTCC=clang-5.0 defconfig && make -j32 HOSTCC=clang-5.0 CC=clang-5.0 If you don't have clang installed in your system, you can use this simple docker setup to compile the kernel with clang: wget https://raw.githubusercontent.com/bulwahn/linux-kernel-analysis/master/docker/kernel-clang/Dockerfile && \ docker build -t kernel-clang . && \ docker run -v :/linux/ kernel-clang /bin/sh -c "cd linux && make CC=clang-5.0 clean && make HOSTCC=clang-5.0 defconfig && make -j32 HOSTCC=clang-5.0 CC=clang-5.0" While we were doing our analysis on 4.15, we noticed that you already resolved this warning on linux-next with your work in commit bb911536f07e ("drm/i915: Eliminate pll->state usage from bxt_calc_pll_link()"). So, since it is resolved on linux-next and we expect that this commit will be merged in the merge window for 4.16, there is probably nothing further to do. Linux 4.15 is shipped with this clang warning, but we don't see the crucial need to provide a backport commit to the stable branch for 4.15. We just wanted to inform you about our analysis of this clang warning. Ultimately the final call if you would like to address this clang warning in 4.15 is yours. Best regards, Ozan & Lukas From greg at kroah.com Thu Feb 1 18:02:40 2018 From: greg at kroah.com (Greg KH) Date: Thu, 1 Feb 2018 19:02:40 +0100 Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: References: Message-ID: <20180201180240.GA28042@kroah.com> On Thu, Feb 01, 2018 at 06:33:30PM +0100, Ozan Alpay wrote: > Dear Rodrigo Vivi, Ville Syrj?l?, > > My name is Ozan Alpay, and I am a student mentored by Lukas Bulwahn. We > intend to use static analysis tools on the kernel source to identify, > analyze and report issues. As a very first step, we are looking into > clang compiler warnings and will then move to more sophisticated tools. > > When compiling Linux 4.15 with clang, we have discovered that your commit > 2952cd6fb4cc ("drm/i915: Let's use more enum intel_dpll_id pll_id.") > introduced the following warning: > > drivers/gpu/drm/i915/intel_ddi.c:1481:30: warning: implicit conversion from enumeration type 'enum port' to different enumeration type 'enum intel_dpll_id' [-Wenum-conversion] > enum intel_dpll_id pll_id = port; > > To reproduce it, you can compile Linux 4.15 with clang with this command: > > make HOSTCC=clang-5.0 defconfig && make -j32 HOSTCC=clang-5.0 CC=clang-5.0 > > If you don't have clang installed in your system, you can use this simple > docker setup to compile the kernel with clang: > > wget https://raw.githubusercontent.com/bulwahn/linux-kernel-analysis/master/docker/kernel-clang/Dockerfile && \ > docker build -t kernel-clang . && \ > docker run -v :/linux/ kernel-clang /bin/sh -c "cd linux && make CC=clang-5.0 clean && make HOSTCC=clang-5.0 defconfig && make -j32 HOSTCC=clang-5.0 CC=clang-5.0" > > While we were doing our analysis on 4.15, we noticed that you already > resolved this warning on linux-next with your work in commit bb911536f07e > ("drm/i915: Eliminate pll->state usage from bxt_calc_pll_link()"). So, > since it is resolved on linux-next and we expect that this commit will be > merged in the merge window for 4.16, there is probably nothing further to > do. > > Linux 4.15 is shipped with this clang warning, but we don't see the > crucial need to provide a backport commit to the stable branch for 4.15. > We just wanted to inform you about our analysis of this clang warning. > Ultimately the final call if you would like to address this clang warning > in 4.15 is yours. Note, I have not taken "clang warning fixes" for stable kernel updates in the past, and I doubt I will in the future, unless the tree "builds clean" with clang. If it eventually gets there, then yes, I will do that. Note, if you are going to email this out to everyone who fixes a warning message, you might want to reconsider it. That's going to be a lot of work, and for people who have already fixed an issue, it's kind of pointless to just remind them of work they have done in the past, right? What is the goal of these types of emails? thanks, greg k-h From o at zgur.org Thu Feb 1 19:27:44 2018 From: o at zgur.org (Ozgur) Date: Thu, 01 Feb 2018 22:27:44 +0300 Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: <20180201180240.GA28042@kroah.com> References: <20180201180240.GA28042@kroah.com> Message-ID: <116291517513264@web58o.yandex.ru> 01.02.2018, 21:03, "Greg KH" : > On Thu, Feb 01, 2018 at 06:33:30PM +0100, Ozan Alpay wrote: >> ?Dear Rodrigo Vivi, Ville Syrj?l?, >> >> ?My name is Ozan Alpay, and I am a student mentored by Lukas Bulwahn. We Hi Ozan, why did you send e-mail to kernel development e-mail list? >> ?intend to use static analysis tools on the kernel source to identify, >> ?analyze and report issues. As a very first step, we are looking into >> ?clang compiler warnings and will then move to more sophisticated tools. >> >> ?When compiling Linux 4.15 with clang, we have discovered that your commit >> ?2952cd6fb4cc ("drm/i915: Let's use more enum intel_dpll_id pll_id.") >> ?introduced the following warning: >> >> ?drivers/gpu/drm/i915/intel_ddi.c:1481:30: warning: implicit conversion from enumeration type 'enum port' to different enumeration type 'enum intel_dpll_id' [-Wenum-conversion] >> ?????????enum intel_dpll_id pll_id = port; >> >> ?To reproduce it, you can compile Linux 4.15 with clang with this command: >> >> ?make HOSTCC=clang-5.0 defconfig && make -j32 HOSTCC=clang-5.0 CC=clang-5.0 >> >> ?If you don't have clang installed in your system, you can use this simple >> ?docker setup to compile the kernel with clang: >> >> ?wget https://raw.githubusercontent.com/bulwahn/linux-kernel-analysis/master/docker/kernel-clang/Dockerfile && \ >> ?docker build -t kernel-clang . && \ >> ?docker run -v :/linux/ kernel-clang /bin/sh -c "cd linux && make CC=clang-5.0 clean && make HOSTCC=clang-5.0 defconfig && make -j32 HOSTCC=clang-5.0 CC=clang-5.0" >> >> ?While we were doing our analysis on 4.15, we noticed that you already >> ?resolved this warning on linux-next with your work in commit bb911536f07e >> ?("drm/i915: Eliminate pll->state usage from bxt_calc_pll_link()"). So, >> ?since it is resolved on linux-next and we expect that this commit will be >> ?merged in the merge window for 4.16, there is probably nothing further to >> ?do. >> >> ?Linux 4.15 is shipped with this clang warning, but we don't see the >> ?crucial need to provide a backport commit to the stable branch for 4.15. >> ?We just wanted to inform you about our analysis of this clang warning. >> ?Ultimately the final call if you would like to address this clang warning >> ?in 4.15 is yours. > > Note, I have not taken "clang warning fixes" for stable kernel updates > in the past, and I doubt I will in the future, unless the tree "builds > clean" with clang. If it eventually gets there, then yes, I will do > that. > > Note, if you are going to email this out to everyone who fixes a warning > message, you might want to reconsider it. That's going to be a lot of > work, and for people who have already fixed an issue, it's kind of > pointless to just remind them of work they have done in the past, right? > > What is the goal of these types of emails? > > thanks, > > greg k-h Ozgur From lukas.bulwahn at gmail.com Thu Feb 1 22:13:09 2018 From: lukas.bulwahn at gmail.com (Lukas Bulwahn) Date: Thu, 1 Feb 2018 23:13:09 +0100 (CET) Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: <20180201180240.GA28042@kroah.com> References: <20180201180240.GA28042@kroah.com> Message-ID: Hi Greg, On Thu, 1 Feb 2018, Greg KH wrote: > On Thu, Feb 01, 2018 at 06:33:30PM +0100, Ozan Alpay wrote: > > Dear Rodrigo Vivi, Ville Syrj?l?, > > > > My name is Ozan Alpay, and I am a student mentored by Lukas Bulwahn. We > > intend to use static analysis tools on the kernel source to identify, > > analyze and report issues. As a very first step, we are looking into > > clang compiler warnings and will then move to more sophisticated tools. > > > > [...] > > > > Linux 4.15 is shipped with this clang warning, but we don't see the > > crucial need to provide a backport commit to the stable branch for 4.15. > > We just wanted to inform you about our analysis of this clang warning. > > Ultimately the final call if you would like to address this clang warning > > in 4.15 is yours. > > Note, I have not taken "clang warning fixes" for stable kernel updates > in the past, and I doubt I will in the future, unless the tree "builds > clean" with clang. If it eventually gets there, then yes, I will do > that. > > Note, if you are going to email this out to everyone who fixes a warning > message, you might want to reconsider it. That's going to be a lot of > work, and for people who have already fixed an issue, it's kind of > pointless to just remind them of work they have done in the past, right? > > What is the goal of these types of emails? > We are interested in providing useful information on potential bugs or bug patterns that we get from static analysis tools, after we pre-assess them and manually select them to send to the review process of the patch submission. For me, the clang warnings were an easy starting point for a student to set up and look at, compared to much more sophisticated tools, such as coccinelle, sparse or new tools for the kernel development, such as CMBC or facebook's Infer. Once we really understand which tools are useful and which information can be quickly pre-assessed and sent out in a useful way without just creating more noise in the discussion, I would have contacted the 0-day infrastructure team or the kernelci.org team to continue the discussion how to include our first setup into a proper semi-automated service. Using the clang warnings, I wanted to explore how this would even potentially work. Considering clang, of course, currently, we cannot compile the whole kernel with all possible kernel configurations with clang, but I believe Nick Desaulniers, Matthias Kaehlcke and others are already working on that and are getting close to this goal. Hence, assuming they will be successful soon, I wanted to explore the next step of using static analysis tools around the clang/LLVM compiler. Actually, v4.15 builds almost "cleanly" with clang: For defconfig, there are only two clang compiler warnings and the one that we looked into deeper here is already resolved in linux-next, so chances are actually high that we might get to this "builds clean" soon-ish, at least for defconfig. Concerning clang warnings and how to progress towards that goal of building cleanly, my strategy is to identify when new clang compiler warnings are introduced and just point these warnings out as code smells during the review discussion before they are merged into the first maintainer tree. If we manually inspect these clang warnings to make sure that they are genuine code smells of some "imprecise implementation" before we send them to the mailing list, I would hope that they are of some value for the developer in the submission process and he/she could address the warning in a patch v2 while he/she is reacting to the other review comments from the human reviewers. At best, I always considered them as useful information during the review process, but I certainly DO NOT want to start patching the kernel due to clang warnings. The chances/risk that we just break more due to naively fixing warnings without proper understanding is much higher than the benefit of actually improving the situation. If I recall correctly, I think this is also one of the lessons learned from motivating newcomers to address warnings in previous kernel newbies activities. Greg, do you think it is worthwhile to invest some effort to move towards the goal "kernel builds cleanly with clang"? Would you agree that providing information during the patch review is a good way to move forward to this goal if we find a suitable manner to provide this feedback quickly and cleanly at this very early stage of development? If not, we will immediately stop to move in this direction and this is the first and last email that you have seen of this kind, and we will have to come up with better/other ideas around work on the Linux kernel. If so, we will continue in the direction sketched above, and I think I just have to point out and apologize for the two obvious things that we did wrong in this specific case here: - We noticed that there were further changes in linux-next, but we thought that our investigation on v4.15 was valuable nevertheless for the developers that had touched the source code that we looked at, although, there is nothing to be done if commits from linux-next are merged into Linus' tree soon. Taking your response, we have clearly been WRONG here, overestimating our contribution versus the noise ratio that we contribute to. - We looked at a clang warning, for which we could only provide the information on this clang warning at this very late stage, i.e., when the commit under investigation has already been merged and the kernel was released. So pointing out shortcoming of that kind seems to have no value, as you, Greg, would not backport commits to stable anyway. This has been both errors on my side as a mentor. After my student has started this week and has worked hard for a week learning a lot about Linux kernel development and all the tools around it, I did not want to discourage him and say that the goal set at the beginning of the week to identify and report a code smell on one commit on the mailing list has not been achieved as for the reasons above. Instead, we decided to send it out and were interested in the general reception of our work of this first week. I apologize for that and hope we can leave the specific reported issue now just rest in peace. This experiment shows that I still need to improve my understanding how to contribute properly to the kernel development. At least to me, the policy on clang warnings was not clear; and I have learned this now in this more indirect way. We only sent out this one email to see if clang warnings are of interest at all, and we are glad that you came back to us so quickly with feedback. Greg, if you can continue to be a sparing partner and point out when we are moving in the wrong direction, we will try our best to understand how we can contribute to turn results from bug finders and static analysis tools with the manual pre-assessment we can do into valuable contributions on the mailing list and the linux kernel development. We certainly do not intend to spam the mailing list with reports of findings nobody cares about. Best regards, Lukas From jani.nikula at linux.intel.com Fri Feb 2 08:36:18 2018 From: jani.nikula at linux.intel.com (Jani Nikula) Date: Fri, 02 Feb 2018 10:36:18 +0200 Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: References: <20180201180240.GA28042@kroah.com> Message-ID: <87372jkcu5.fsf@intel.com> On Thu, 01 Feb 2018, Lukas Bulwahn wrote: > Hi Greg, > > On Thu, 1 Feb 2018, Greg KH wrote: > >> On Thu, Feb 01, 2018 at 06:33:30PM +0100, Ozan Alpay wrote: >> > Dear Rodrigo Vivi, Ville Syrj?l?, >> > >> > My name is Ozan Alpay, and I am a student mentored by Lukas Bulwahn. We >> > intend to use static analysis tools on the kernel source to identify, >> > analyze and report issues. As a very first step, we are looking into >> > clang compiler warnings and will then move to more sophisticated tools. >> > >> > [...] >> > >> > Linux 4.15 is shipped with this clang warning, but we don't see the >> > crucial need to provide a backport commit to the stable branch for 4.15. >> > We just wanted to inform you about our analysis of this clang warning. >> > Ultimately the final call if you would like to address this clang warning >> > in 4.15 is yours. >> >> Note, I have not taken "clang warning fixes" for stable kernel updates >> in the past, and I doubt I will in the future, unless the tree "builds >> clean" with clang. If it eventually gets there, then yes, I will do >> that. >> >> Note, if you are going to email this out to everyone who fixes a warning >> message, you might want to reconsider it. That's going to be a lot of >> work, and for people who have already fixed an issue, it's kind of >> pointless to just remind them of work they have done in the past, right? >> >> What is the goal of these types of emails? >> > > We are interested in providing useful information on potential bugs or bug > patterns that we get from static analysis tools, after we pre-assess them > and manually select them to send to the review process of the patch > submission. > > For me, the clang warnings were an easy starting point for a student to > set up and look at, compared to much more sophisticated tools, such as > coccinelle, sparse or new tools for the kernel development, such as CMBC > or facebook's Infer. > > Once we really understand which tools are useful and which information can > be quickly pre-assessed and sent out in a useful way without just creating > more noise in the discussion, I would have contacted the 0-day > infrastructure team or the kernelci.org team to continue the discussion > how to include our first setup into a proper semi-automated service. > > Using the clang warnings, I wanted to explore how this would even > potentially work. > > Considering clang, of course, currently, we cannot compile the whole > kernel with all possible kernel configurations with clang, but I believe > Nick Desaulniers, Matthias Kaehlcke and others are already working on > that and are getting close to this goal. Hence, assuming they will be > successful soon, I wanted to explore the next step of using static > analysis tools around the clang/LLVM compiler. > > Actually, v4.15 builds almost "cleanly" with clang: For defconfig, there > are only two clang compiler warnings and the one that we looked into > deeper here is already resolved in linux-next, so chances are actually > high that we might get to this "builds clean" soon-ish, at least for > defconfig. > > Concerning clang warnings and how to progress towards that goal of > building cleanly, my strategy is to identify when new clang compiler > warnings are introduced and just point these warnings out as code smells > during the review discussion before they are merged into the > first maintainer tree. If we manually inspect these clang warnings > to make sure that they are genuine code smells of some "imprecise > implementation" before we send them to the mailing list, I would hope that > they are of some value for the developer in the submission process and > he/she could address the warning in a patch v2 while he/she is reacting to > the other review comments from the human reviewers. > > At best, I always considered them as useful information during the review > process, but I certainly DO NOT want to start patching the kernel due to > clang warnings. The chances/risk that we just break more due to naively > fixing warnings without proper understanding is much higher than the > benefit of actually improving the situation. If I recall correctly, I > think this is also one of the lessons learned from motivating newcomers > to address warnings in previous kernel newbies activities. > > Greg, do you think it is worthwhile to invest some effort to move > towards the goal "kernel builds cleanly with clang"? > Would you agree that providing information during the patch review is a > good way to move forward to this goal if we find a suitable manner to > provide this feedback quickly and cleanly at this very early stage of > development? > > If not, we will immediately stop to move in this direction and this is the > first and last email that you have seen of this kind, and we will have to > come up with better/other ideas around work on the Linux kernel. > > If so, we will continue in the direction sketched above, and I think I > just have to point out and apologize for the two obvious things that we > did wrong in this specific case here: > > - We noticed that there were further changes in linux-next, but we > thought that our investigation on v4.15 was valuable nevertheless > for the developers that had touched the source code that we looked at, > although, there is nothing to be done if commits from linux-next are > merged into Linus' tree soon. Taking your response, we have clearly > been WRONG here, overestimating our contribution versus the noise > ratio that we contribute to. > > - We looked at a clang warning, for which we could only provide the > information on this clang warning at this very late stage, i.e., when > the commit under investigation has already been merged and the kernel > was released. So pointing out shortcoming of that kind seems to have > no value, as you, Greg, would not backport commits to stable anyway. > > This has been both errors on my side as a mentor. After my student > has started this week and has worked hard for a week learning a lot about > Linux kernel development and all the tools around it, I did not want to > discourage him and say that the goal set at the beginning of the week to > identify and report a code smell on one commit on the mailing list has > not been achieved as for the reasons above. Instead, we decided to send it > out and were interested in the general reception of our work of this first > week. > > I apologize for that and hope we can leave the specific reported issue now > just rest in peace. > > This experiment shows that I still need to improve my understanding how > to contribute properly to the kernel development. At least to me, the > policy on clang warnings was not clear; and I have learned this now in > this more indirect way. > > We only sent out this one email to see if clang warnings are of interest > at all, and we are glad that you came back to us so quickly with feedback. > > Greg, if you can continue to be a sparing partner and point out when > we are moving in the wrong direction, we will try our best to understand > how we can contribute to turn results from bug finders and static analysis > tools with the manual pre-assessment we can do into valuable contributions > on the mailing list and the linux kernel development. > > We certainly do not intend to spam the mailing list with reports of > findings nobody cares about. Being brutally honest, please write shorter reports and shorter emails to the lists. The static analysis reports are welcome, but only when 1) we didn't already fix it in linux-next, or 2) it reveals an actual bug, not just a warning, warranting a backport. Thanks, Jani. -- Jani Nikula, Intel Open Source Technology Center From lukas.bulwahn at gmail.com Fri Feb 2 09:56:36 2018 From: lukas.bulwahn at gmail.com (Lukas Bulwahn) Date: Fri, 2 Feb 2018 10:56:36 +0100 (CET) Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: <87372jkcu5.fsf@intel.com> References: <20180201180240.GA28042@kroah.com> <87372jkcu5.fsf@intel.com> Message-ID: On Fri, 2 Feb 2018, Jani Nikula wrote: > Being brutally honest, please write shorter reports and shorter emails > to the lists. > > The static analysis reports are welcome, but only when 1) we didn't > already fix it in linux-next, or 2) it reveals an actual bug, not just a > warning, warranting a backport. That will be our policy. Lukas From gregkh at linuxfoundation.org Fri Feb 2 10:06:13 2018 From: gregkh at linuxfoundation.org (Greg KH) Date: Fri, 2 Feb 2018 11:06:13 +0100 Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: References: <20180201180240.GA28042@kroah.com> <87372jkcu5.fsf@intel.com> Message-ID: <20180202100613.GA21492@kroah.com> On Fri, Feb 02, 2018 at 10:56:36AM +0100, Lukas Bulwahn wrote: > On Fri, 2 Feb 2018, Jani Nikula wrote: > > > Being brutally honest, please write shorter reports and shorter emails > > to the lists. > > > > The static analysis reports are welcome, but only when 1) we didn't > > already fix it in linux-next, or 2) it reveals an actual bug, not just a > > warning, warranting a backport. > > That will be our policy. Great! Also a few other things to be aware of when working with the Linux kernel community, and to try to answer some of your longer original email querstions: - don't scatter emails to tons of lists at the same time. If you use scripts/get_maintainer.pl on a file, it will tell you exactly who and what list to notify of an issue found. - when finding an issue, again, always check linux-next as that contains up to the past 3 months of work. Don't duplicate stuff that others have already done, as that doesn't help anyone out. - for stable kernel patches, please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html as to how to report a patch to be included in a stable kernel release (hint, just send the git hash to the list when it is in Linus's tree and ask for it to be included, as well as what trees you think it should be included in.) - If clang now builds the kernel "cleanly", yes, I want to take warning fixes in the stable tree. And even better yet, if you keep working to ensure the tree is "clean", that would be wonderful. Hope this helps! greg k-h From jani.nikula at linux.intel.com Fri Feb 2 10:44:38 2018 From: jani.nikula at linux.intel.com (Jani Nikula) Date: Fri, 02 Feb 2018 12:44:38 +0200 Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: <20180202100613.GA21492@kroah.com> References: <20180201180240.GA28042@kroah.com> <87372jkcu5.fsf@intel.com> <20180202100613.GA21492@kroah.com> Message-ID: <87h8qzisbt.fsf@intel.com> +Knut, Fengguang On Fri, 02 Feb 2018, Greg KH wrote: > - If clang now builds the kernel "cleanly", yes, I want to take > warning fixes in the stable tree. And even better yet, if you > keep working to ensure the tree is "clean", that would be > wonderful. So we can run sparse using 'make C=1' and friends, or other static analysis tools using 'make CHECK=foo C=1', as long as the passed command line params work. There was work by Knut to extend this make checker stuff [1]. Since mixing different HOSTCC's in a single workdir seems like a bad idea, I wonder how hard it would be to make clang work like this: $ make CHECK=clang C=1 Or using Knut's wrapper. Feels like that could increase the use of clang for static analysis of patches. BR, Jani. [1] http://mid.mail-archive.com/cover.5b56d020b8e826a7da33b1823c059acd0c123f8b.1515072782.git-series.knut.omang at oracle.com -- Jani Nikula, Intel Open Source Technology Center From knut.omang at oracle.com Fri Feb 2 11:04:32 2018 From: knut.omang at oracle.com (Knut Omang) Date: Fri, 02 Feb 2018 12:04:32 +0100 Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: <87h8qzisbt.fsf@intel.com> References: <20180201180240.GA28042@kroah.com> <87372jkcu5.fsf@intel.com> <20180202100613.GA21492@kroah.com> <87h8qzisbt.fsf@intel.com> Message-ID: <1517569472.3118.257.camel@oracle.com> On Fri, 2018-02-02 at 12:44 +0200, Jani Nikula wrote: > +Knut, Fengguang > > On Fri, 02 Feb 2018, Greg KH wrote: > > - If clang now builds the kernel "cleanly", yes, I want to take > > warning fixes in the stable tree. And even better yet, if you > > keep working to ensure the tree is "clean", that would be > > wonderful. > > So we can run sparse using 'make C=1' and friends, or other static > analysis tools using 'make CHECK=foo C=1', as long as the passed command > line params work. There was work by Knut to extend this make checker > stuff [1]. Since mixing different HOSTCC's in a single workdir seems > like a bad idea, I wonder how hard it would be to make clang work like > this: > > $ make CHECK=clang C=1 > > Or using Knut's wrapper. Feels like that could increase the use of clang > for static analysis of patches. Yes, definitely a natural addition to the set of tools supported by runchecks to also support using alternate compiler(s) as "checkers" - I guess the same would apply for people compiling with clang - that they don't accidentally generate warnings with gcc.. Thanks, Knut > BR, > Jani. > > > [1] http://mid.mail-archive.com/cover.5b56d020b8e826a7da33b1823c059acd0c123f8b.151507278 > 2.git-series.knut.omang at oracle.com > > > From gregkh at linuxfoundation.org Fri Feb 2 13:13:28 2018 From: gregkh at linuxfoundation.org (Greg KH) Date: Fri, 2 Feb 2018 14:13:28 +0100 Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: <87h8qzisbt.fsf@intel.com> References: <20180201180240.GA28042@kroah.com> <87372jkcu5.fsf@intel.com> <20180202100613.GA21492@kroah.com> <87h8qzisbt.fsf@intel.com> Message-ID: <20180202131328.GA4456@kroah.com> On Fri, Feb 02, 2018 at 12:44:38PM +0200, Jani Nikula wrote: > > +Knut, Fengguang > > On Fri, 02 Feb 2018, Greg KH wrote: > > - If clang now builds the kernel "cleanly", yes, I want to take > > warning fixes in the stable tree. And even better yet, if you > > keep working to ensure the tree is "clean", that would be > > wonderful. > > So we can run sparse using 'make C=1' and friends, or other static > analysis tools using 'make CHECK=foo C=1', as long as the passed command > line params work. There was work by Knut to extend this make checker > stuff [1]. Since mixing different HOSTCC's in a single workdir seems > like a bad idea, I wonder how hard it would be to make clang work like > this: > > $ make CHECK=clang C=1 > > Or using Knut's wrapper. Feels like that could increase the use of clang > for static analysis of patches. Why not just build with clang itself: make CC=clang thanks, greg k-h From jani.nikula at linux.intel.com Fri Feb 2 14:37:55 2018 From: jani.nikula at linux.intel.com (Jani Nikula) Date: Fri, 02 Feb 2018 16:37:55 +0200 Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: <20180202131328.GA4456@kroah.com> References: <20180201180240.GA28042@kroah.com> <87372jkcu5.fsf@intel.com> <20180202100613.GA21492@kroah.com> <87h8qzisbt.fsf@intel.com> <20180202131328.GA4456@kroah.com> Message-ID: <871si3ihj0.fsf@intel.com> On Fri, 02 Feb 2018, Greg KH wrote: > On Fri, Feb 02, 2018 at 12:44:38PM +0200, Jani Nikula wrote: >> >> +Knut, Fengguang >> >> On Fri, 02 Feb 2018, Greg KH wrote: >> > - If clang now builds the kernel "cleanly", yes, I want to take >> > warning fixes in the stable tree. And even better yet, if you >> > keep working to ensure the tree is "clean", that would be >> > wonderful. >> >> So we can run sparse using 'make C=1' and friends, or other static >> analysis tools using 'make CHECK=foo C=1', as long as the passed command >> line params work. There was work by Knut to extend this make checker >> stuff [1]. Since mixing different HOSTCC's in a single workdir seems >> like a bad idea, I wonder how hard it would be to make clang work like >> this: >> >> $ make CHECK=clang C=1 >> >> Or using Knut's wrapper. Feels like that could increase the use of clang >> for static analysis of patches. > > Why not just build with clang itself: > make CC=clang Same as HOSTCC, mixing different CC's in a single build dir seems like a bad idea. Sure, everyone can setup a separate build dir for clang, but IMHO having 'make CHECK=clang C=1' work has least resistance. YMMV. BR, Jani. -- Jani Nikula, Intel Open Source Technology Center From ruben at mrbrklyn.com Fri Feb 2 14:33:39 2018 From: ruben at mrbrklyn.com (Ruben Safir) Date: Fri, 2 Feb 2018 09:33:39 -0500 Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: <20180201180240.GA28042@kroah.com> References: <20180201180240.GA28042@kroah.com> Message-ID: <20180202143339.GA769@www2.mrbrklyn.com> > > What is the goal of these types of emails? > even more so on this mailing list. It almost feels like guerilla advertising for Clang. > thanks, > > greg k-h > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies -- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 From gregkh at linuxfoundation.org Fri Feb 2 15:50:22 2018 From: gregkh at linuxfoundation.org (Greg KH) Date: Fri, 2 Feb 2018 16:50:22 +0100 Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: <871si3ihj0.fsf@intel.com> References: <20180201180240.GA28042@kroah.com> <87372jkcu5.fsf@intel.com> <20180202100613.GA21492@kroah.com> <87h8qzisbt.fsf@intel.com> <20180202131328.GA4456@kroah.com> <871si3ihj0.fsf@intel.com> Message-ID: <20180202155022.GA29918@kroah.com> On Fri, Feb 02, 2018 at 04:37:55PM +0200, Jani Nikula wrote: > On Fri, 02 Feb 2018, Greg KH wrote: > > On Fri, Feb 02, 2018 at 12:44:38PM +0200, Jani Nikula wrote: > >> > >> +Knut, Fengguang > >> > >> On Fri, 02 Feb 2018, Greg KH wrote: > >> > - If clang now builds the kernel "cleanly", yes, I want to take > >> > warning fixes in the stable tree. And even better yet, if you > >> > keep working to ensure the tree is "clean", that would be > >> > wonderful. > >> > >> So we can run sparse using 'make C=1' and friends, or other static > >> analysis tools using 'make CHECK=foo C=1', as long as the passed command > >> line params work. There was work by Knut to extend this make checker > >> stuff [1]. Since mixing different HOSTCC's in a single workdir seems > >> like a bad idea, I wonder how hard it would be to make clang work like > >> this: > >> > >> $ make CHECK=clang C=1 > >> > >> Or using Knut's wrapper. Feels like that could increase the use of clang > >> for static analysis of patches. > > > > Why not just build with clang itself: > > make CC=clang > > Same as HOSTCC, mixing different CC's in a single build dir seems like a > bad idea. Sure, everyone can setup a separate build dir for clang, but > IMHO having 'make CHECK=clang C=1' work has least resistance. YMMV. "O=some_output_dir" is your friend. If you aren't doing that already for your test builds, you don't know what you are missing :) thanks, greg k-h From knut.omang at oracle.com Sat Feb 3 07:04:05 2018 From: knut.omang at oracle.com (Knut Omang) Date: Sat, 03 Feb 2018 08:04:05 +0100 Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: <20180202155022.GA29918@kroah.com> References: <20180201180240.GA28042@kroah.com> <87372jkcu5.fsf@intel.com> <20180202100613.GA21492@kroah.com> <87h8qzisbt.fsf@intel.com> <20180202131328.GA4456@kroah.com> <871si3ihj0.fsf@intel.com> <20180202155022.GA29918@kroah.com> Message-ID: <1517641445.3118.342.camel@oracle.com> On Fri, 2018-02-02 at 16:50 +0100, Greg KH wrote: > On Fri, Feb 02, 2018 at 04:37:55PM +0200, Jani Nikula wrote: > > On Fri, 02 Feb 2018, Greg KH wrote: > > > On Fri, Feb 02, 2018 at 12:44:38PM +0200, Jani Nikula wrote: > > >> > > >> +Knut, Fengguang > > >> > > >> On Fri, 02 Feb 2018, Greg KH wrote: > > >> > - If clang now builds the kernel "cleanly", yes, I want to take > > >> > warning fixes in the stable tree. And even better yet, if you > > >> > keep working to ensure the tree is "clean", that would be > > >> > wonderful. > > >> > > >> So we can run sparse using 'make C=1' and friends, or other static > > >> analysis tools using 'make CHECK=foo C=1', as long as the passed command > > >> line params work. There was work by Knut to extend this make checker > > >> stuff [1]. Since mixing different HOSTCC's in a single workdir seems > > >> like a bad idea, I wonder how hard it would be to make clang work like > > >> this: > > >> > > >> $ make CHECK=clang C=1 > > >> > > >> Or using Knut's wrapper. Feels like that could increase the use of clang > > >> for static analysis of patches. > > > > > > Why not just build with clang itself: > > > make CC=clang > > > > Same as HOSTCC, mixing different CC's in a single build dir seems like a > > bad idea. Sure, everyone can setup a separate build dir for clang, but > > IMHO having 'make CHECK=clang C=1' work has least resistance. YMMV. > > "O=some_output_dir" is your friend. If you aren't doing that already > for your test builds, you don't know what you are missing :) I use O= a lot myself - so good not to have all the output files "pollute" the source tree, and to be able to switch branches and compile without having to recompile everything by having multiple O= set up. I think what my runchecks wrapper script brings in addition is the ability to to a number of checks which may or may not pass, even return error codes, from the same 'make' command and configure what errors to fix now and what to postpone/ignore (and thus not fail from). As an example, I just tried clang (on v4.15-rc6) with: cd $HOME/src/kernel make O=$HOME/build/kernel/clang cd $HOME/build/kernel/clang make and it fails to compile for me in arch/x86/xen/mmu_pv.o. If I'd want to just make sure that some patches did not introduce new errors with clang, I would waste some time with unrelated errors, and there will be noise in the output, also consuming personal "cycles". I haven't really looked at the details of much of what clang outputs of errors yet, but I can imagine that specific errors reported by clang might be useful to correct even in old kernels, where some files inevitably will fail to compile like this. This would be easy to handle with runchecks using a few exceptions for those problems/files not yet fixed, allowing a run to easily detect (while compiling with gcc as the main compiler) that no new clang errors were introduced of any other kind than those suppressed. Thanks, Knut > > thanks, > > greg k-h From dwmw2 at infradead.org Fri Feb 9 16:18:33 2018 From: dwmw2 at infradead.org (David Woodhouse) Date: Fri, 9 Feb 2018 16:18:33 +0000 Subject: [llvmlinux] [RFC HACK] Make clang hate percpu.h less in 32-bit mode Message-ID: <20180209161833.4605-1-dwmw2@infradead.org> Neither clang nor GCC like this very much with -m32: long long ret; asm ("movb $5, %0" : "=q" (ret)); However, GCC can tolerate this variant: long long ret; switch (sizeof(ret)) { case 1: asm ("movb $5, %0" : "=q" (ret)); case 8: ; } Clang, on the other hand, won't accept that because it validates the inline asm for the '1' case *before* the optimisation phase where it realises that it wouldn't have to emit it anyway. This patch puts some casts in to make clang less unhappy. I don't like it very much. Note that we don't have the same problem for the "=r" case, where a 64-bit value *also* doesn't fit. This is because even if it *does* have to emit it, clang will happily and silently do so even though it's clearly bogus: long long ret; asm ("movl $5, %0" : "=r" (ret)); $ clang -c -o q.o q.c -m32 $ gcc -c -o q.o q.c -m32 q.c: In function ?foo?: q.c:6:1: warning: unsupported size for integer register --- arch/x86/include/asm/percpu.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index ba3c523aaf16..3b0e413670e4 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -99,7 +99,7 @@ do { \ case 1: \ asm(op "b %1,"__percpu_arg(0) \ : "+m" (var) \ - : "qi" ((pto_T__)(val))); \ + : "qi" ((unsigned char)(unsigned long)(val))); \ break; \ case 2: \ asm(op "w %1,"__percpu_arg(0) \ @@ -144,7 +144,7 @@ do { \ else \ asm("addb %1, "__percpu_arg(0) \ : "+m" (var) \ - : "qi" ((pao_T__)(val))); \ + : "qi" ((unsigned char)(unsigned long)(val))); \ break; \ case 2: \ if (pao_ID__ == 1) \ @@ -182,12 +182,14 @@ do { \ #define percpu_from_op(op, var) \ ({ \ + unsigned char pfo_u8__; \ typeof(var) pfo_ret__; \ switch (sizeof(var)) { \ case 1: \ asm(op "b "__percpu_arg(1)",%0" \ - : "=q" (pfo_ret__) \ + : "=q" (pfo_u8__) \ : "m" (var)); \ + pfo_ret__ = (typeof(var))(unsigned long)pfo_u8__; \ break; \ case 2: \ asm(op "w "__percpu_arg(1)",%0" \ @@ -211,12 +213,14 @@ do { \ #define percpu_stable_op(op, var) \ ({ \ + unsigned char pfo_u8__; \ typeof(var) pfo_ret__; \ switch (sizeof(var)) { \ case 1: \ asm(op "b "__percpu_arg(P1)",%0" \ - : "=q" (pfo_ret__) \ + : "=q" (pfo_u8__) \ : "p" (&(var))); \ + pfo_ret__ = (typeof(var))(unsigned long)pfo_u8__; \ break; \ case 2: \ asm(op "w "__percpu_arg(P1)",%0" \ -- 2.14.3 From ruben at mrbrklyn.com Mon Feb 5 18:46:23 2018 From: ruben at mrbrklyn.com (Ruben Safir) Date: Mon, 05 Feb 2018 18:46:23 -0000 Subject: [llvmlinux] clang warning: implicit conversion in intel_ddi.c:1481 In-Reply-To: References: <20180201180240.GA28042@kroah.com> Message-ID: <20180205184616.GA29539@www2.mrbrklyn.com> > > We are interested who is we?