[PATCH v3] media: cedrus: Remove global IRQ spin lock from the driver
We initially introduced a spin lock to ensure that the VPU registers are not accessed concurrently between our setup function and IRQ handler. The V4L2 M2M API ensures that only one decoding job runs at a time, so the interrupt signaling the end of decoding will not occur while the next picture is being configured. Spurious interrupts are taken care of in the handler, by checking that we have a valid M2M context and a decoding status available before marking the buffers as done. In addition, holding a spin lock could be problematic if non-atomic operations are required in the setup process for future codec support. As a result, remove the global IRQ spin lock. Signed-off-by: Paul Kocialkowski Acked-by: Maxime Ripard --- Changes since v2: * Rebased on top of the next media tree. Changes since v1: * Reworked commit message as suggested by Maxime. drivers/staging/media/sunxi/cedrus/cedrus.c | 1 - drivers/staging/media/sunxi/cedrus/cedrus.h | 2 -- drivers/staging/media/sunxi/cedrus/cedrus_dec.c | 9 - drivers/staging/media/sunxi/cedrus/cedrus_hw.c| 13 + drivers/staging/media/sunxi/cedrus/cedrus_video.c | 5 - 5 files changed, 1 insertion(+), 29 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index da790db450d2..edb04a696d70 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -279,7 +279,6 @@ static int cedrus_probe(struct platform_device *pdev) dev->dec_ops[CEDRUS_CODEC_MPEG2] = &cedrus_dec_ops_mpeg2; mutex_init(&dev->dev_mutex); - spin_lock_init(&dev->irq_lock); ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); if (ret) { diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 3f61248c57ac..3acfdcf83691 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -105,8 +105,6 @@ struct cedrus_dev { /* Device file mutex */ struct mutexdev_mutex; - /* Interrupt spinlock */ - spinlock_t irq_lock; void __iomem*base; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c index e40180a33951..6c5e310a7cf7 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c @@ -28,7 +28,6 @@ void cedrus_device_run(void *priv) struct cedrus_dev *dev = ctx->dev; struct cedrus_run run = { 0 }; struct media_request *src_req; - unsigned long flags; run.src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); run.dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); @@ -39,8 +38,6 @@ void cedrus_device_run(void *priv) if (src_req) v4l2_ctrl_request_setup(src_req, &ctx->hdl); - spin_lock_irqsave(&ctx->dev->irq_lock, flags); - switch (ctx->src_fmt.pixelformat) { case V4L2_PIX_FMT_MPEG2_SLICE: run.mpeg2.slice_params = cedrus_find_control_data(ctx, @@ -55,16 +52,10 @@ void cedrus_device_run(void *priv) dev->dec_ops[ctx->current_codec]->setup(ctx, &run); - spin_unlock_irqrestore(&ctx->dev->irq_lock, flags); - /* Complete request(s) controls if needed. */ if (src_req) v4l2_ctrl_request_complete(src_req, &ctx->hdl); - spin_lock_irqsave(&ctx->dev->irq_lock, flags); - dev->dec_ops[ctx->current_codec]->trigger(ctx); - - spin_unlock_irqrestore(&ctx->dev->irq_lock, flags); } diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c index 493e65b17b30..243592a5425e 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c @@ -105,24 +105,17 @@ static irqreturn_t cedrus_irq(int irq, void *data) struct vb2_v4l2_buffer *src_buf, *dst_buf; enum vb2_buffer_state state; enum cedrus_irq_status status; - unsigned long flags; - - spin_lock_irqsave(&dev->irq_lock, flags); ctx = v4l2_m2m_get_curr_priv(dev->m2m_dev); if (!ctx) { v4l2_err(&dev->v4l2_dev, "Instance released before the end of transaction\n"); - spin_unlock_irqrestore(&dev->irq_lock, flags); - return IRQ_NONE; } status = dev->dec_ops[ctx->current_codec]->irq_status(ctx); - if (status == CEDRUS_IRQ_NONE) { - spin_unlock_irqrestore(&dev->irq_lock, flags); + if (status == CEDRUS_IRQ_NONE) return IRQ_NONE; - } dev->dec_ops[ctx->current_codec]->irq_disable(ctx); dev->dec_ops[ctx->current_codec]->irq_clear(ctx); @@ -133,8 +126,6 @@ static irqreturn_t cedrus_irq(int irq, void *data) if (!src_buf ||
Re: [PATCH 0/2] Parenthesis fix and temp vars
On Tue, Nov 27, 2018 at 12:19:07AM +0100, Cristian Sicilia wrote: > In the first patch there is a fix of some parenthesis that terminate > on end of line and some parameters that are not aligned with > previous parenthesis. > > The second patch is a proposal that avoid the long line refactoring > code and using a temporary parameter that will be passed to the > function on next line. Note, please, in the future put "staging:" in your 0/X emails so they sort properly in my inbox and it doesn't look odd... thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Staging : Add RIFFA PCIe driver
On Tue, Nov 27, 2018 at 05:59:48AM +, Cheng Fei Phung wrote: > This patch adds RIFFA PCIe linux driver for > https://github.com/promach/riffa/tree/full_duplex/driver/linux > > This staging driver is modified from this upstream driver at > https://github.com/KastnerRG/riffa/tree/master/driver/linux > > For further details, please refer to > https://github.com/KastnerRG/riffa/pull/31 > > Signed-off-by: Cheng Fei Phung > > --- > Changes in v1: > - added full-duplex capability > > drivers/staging/riffa/Kconfig|5 + > drivers/staging/riffa/Makefile |1 + > drivers/staging/riffa/TODO |7 + > drivers/staging/riffa/circ_queue.c | 188 +++ > drivers/staging/riffa/circ_queue.h | 96 ++ > drivers/staging/riffa/riffa.c| 152 +++ > drivers/staging/riffa/riffa.h| 121 ++ > drivers/staging/riffa/riffa_driver.c | 1643 ++ > drivers/staging/riffa/riffa_driver.h | 131 ++ > 9 files changed, 2344 insertions(+) > create mode 100644 drivers/staging/riffa/Kconfig > create mode 100644 drivers/staging/riffa/Makefile > create mode 100644 drivers/staging/riffa/TODO > create mode 100644 drivers/staging/riffa/circ_queue.c > create mode 100644 drivers/staging/riffa/circ_queue.h > create mode 100644 drivers/staging/riffa/riffa.c > create mode 100644 drivers/staging/riffa/riffa.h > create mode 100644 drivers/staging/riffa/riffa_driver.c > create mode 100644 drivers/staging/riffa/riffa_driver.h > > diff --git a/drivers/staging/riffa/Kconfig b/drivers/staging/riffa/Kconfig > new file mode 100644 > index ..afe5beee1882 > --- /dev/null > +++ b/drivers/staging/riffa/Kconfig > @@ -0,0 +1,5 @@ > +config RIFFA_PCIE > +tristate "a simple framework for communicating data from a host CPU to a > FPGA via a PCI Express bus" > +default n n is always the default, no need to put it :) Also, you have no dependancies at all? Not even PCI? I think PCI is needed here or the build will blow up on non-pci systems, right? And please use tabs in this file. > +help > +Transfers data with full duplex capability using PCIe protocol > diff --git a/drivers/staging/riffa/Makefile b/drivers/staging/riffa/Makefile > new file mode 100644 > index ..79ef3b9b8c8f > --- /dev/null > +++ b/drivers/staging/riffa/Makefile > @@ -0,0 +1 @@ > +obj-$(CONFIG_RIFFA) += riffa.o circ_queue.o riffa_driver.o riffa_mod.o > diff --git a/drivers/staging/riffa/TODO b/drivers/staging/riffa/TODO > new file mode 100644 > index ..5f1b0287cb52 > --- /dev/null > +++ b/drivers/staging/riffa/TODO > @@ -0,0 +1,7 @@ > +TODO: > +- optimize the driver code for further speed improvement although it can now > achieve defined PCIe speed grade > +- solve all the coding style errors from scripts/checkpatch.pl > +- add vendor and device IDs for more supported devices after actual hardware > testing > + > +Please send any patches to Greg Kroah-Hartman > +and Phung Cheng Fei > diff --git a/drivers/staging/riffa/circ_queue.c > b/drivers/staging/riffa/circ_queue.c > new file mode 100644 > index ..fb43ca22e3c0 > --- /dev/null > +++ b/drivers/staging/riffa/circ_queue.c > @@ -0,0 +1,188 @@ > +// -- > +// Copyright (c) 2016, The Regents of the University of California All > +// rights reserved. > +// > +// Redistribution and use in source and binary forms, with or without > +// modification, are permitted provided that the following conditions are > +// met: > +// > +// * Redistributions of source code must retain the above copyright > +// notice, this list of conditions and the following disclaimer. > +// > +// * Redistributions in binary form must reproduce the above > +// copyright notice, this list of conditions and the following > +// disclaimer in the documentation and/or other materials provided > +// with the distribution. > +// > +// * Neither the name of The Regents of the University of California > +// nor the names of its contributors may be used to endorse or > +// promote products derived from this software without specific > +// prior written permission. > +// > +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS > +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT > +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR > +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE > +// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT, > +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, > +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS > +// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND > +// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR > +// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
Re: [linux-sunxi] [PATCH 14/15] arm64: dts: allwinner: h5: Add Video Engine and reserved memory node
Hi, On Thu, 2018-11-15 at 23:35 +0800, Chen-Yu Tsai wrote: > On Thu, Nov 15, 2018 at 10:51 PM Paul Kocialkowski > wrote: > > This adds nodes for the Video Engine and the associated reserved memory > > for the H5. Up to 96 MiB of memory are dedicated to the CMA pool. > > > > The pool is located at the end of the first 256 MiB of RAM so that the > > VPU can access it. It is unclear whether this is still a hard > > requirement for this platform, but it seems safer that way. > > I think we can actually test this. You could move the reserved memory > pool beyond 256 MiB, and have cedrus decode stuff, and try to display > the results. If it's gibberish, or the system crashes, it's likely the > memory access wrapped around at 256 MiB. > > What do you think? I did the test on various platforms and found that starting with the A33, the VPU can map any address in RAM! SO we shouldn't need reserved memory nodes for these devices after all. Cheers, Paul -- Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com signature.asc Description: This is a digitally signed message part ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 07/15] arm64: dts: allwinner: h5: Add system-control node with SRAM C1
Hi, On Fri, 2018-11-30 at 11:38 +0800, Chen-Yu Tsai wrote: > On Fri, Nov 16, 2018 at 12:52 AM Chen-Yu Tsai wrote: > > On Thu, Nov 15, 2018 at 10:50 PM Paul Kocialkowski > > wrote: > > > Add the H5-specific system control node description to its device-tree > > > with support for the SRAM C1 section, that will be used by the video > > > codec node later on. > > > > > > Signed-off-by: Paul Kocialkowski > > > --- > > > arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi | 22 > > > 1 file changed, 22 insertions(+) > > > > > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi > > > b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi > > > index b41dc1aab67d..c2d14b22b8c1 100644 > > > --- a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi > > > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi > > > @@ -94,6 +94,28 @@ > > > }; > > > > > > soc { > > > + system-control@1c0 { > > > + compatible = "allwinner,sun50i-h5-system-control"; > > > + reg = <0x01c0 0x1000>; > > > + #address-cells = <1>; > > > + #size-cells = <1>; > > > + ranges; > > > + > > > + sram_c1: sram@1d0 { > > > + compatible = "mmio-sram"; > > > + reg = <0x01d0 0x8>; > > > > I'll try to check this one tomorrow. > > > > I did find something interesting on the H3: there also seems to be SRAM at > > 0x01dc to 0x01dcfeff , again mapped by the same bits as SRAM C1. > > > > And on the A33, the SRAM C1 range is 0x01d0 to 0x01d478ff. > > > > This was found by mapping the SRAM to the CPU, then using devmem to poke > > around the register range. If there's SRAM, the first read would typically > > return random data, and a subsequent write to it would set some value that > > would be read back correctly. If there's no SRAM, a read either returns 0x0 > > or some random data that can't be overwritten. > > > > You might want to check the other SoCs. > > This range seems to contain stuff other than SRAM, possibly fixed lookup > tables. Since this is entirely unknown, lets just stick to the known full > range instead. Thanks for investigating all this! I also conducted some tests and found that the H5 has its SRAM C1 (marked as SRAM C in the manual) at 0x18000. However for the A64, SRAM C1 gets mapped to 0x1D0. There is also SRAM C at 0x18000 but this one seems unrelated to the VPU and only used by DE2 (as already described in the A64 dt). I share your conclusion that there seems to be more than SRAM in there. Testing with devmem write/read on the start address was reliable as a test, but some chunks in the range did not behave like SRAM (not the same value read). I agree that we should keep the known full range as there are lots of unknowns here. Cheers, Paul > ChenYu > > > > + #address-cells = <1>; > > > + #size-cells = <1>; > > > + ranges = <0 0x01d0 0x8>; > > > + > > > + ve_sram: sram-section@0 { > > > + compatible = > > > "allwinner,sun50i-h5-sram-c1", > > > + > > > "allwinner,sun4i-a10-sram-c1"; > > > + reg = <0x00 0x8>; > > > + }; > > > + }; > > > + }; > > > + > > > mali: gpu@1e8 { > > > compatible = "allwinner,sun50i-h5-mali", > > > "arm,mali-450"; > > > reg = <0x01e8 0x3>; > > > -- > > > 2.19.1 > > > -- Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com signature.asc Description: This is a digitally signed message part ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: android: ion: Remove unused header files
seq_file.h does not need to be included,so remove it. Signed-off-by: Yangtao Li --- drivers/staging/android/ion/ion.c | 1 - drivers/staging/android/ion/ion_system_heap.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 99073325b0c0..0d61e9cd0887 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index 548bb02c0ca6..9ce2c0d7ac17 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include "ion.h" -- 2.17.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[GIT PULL] Staging/IIO driver fixes for 4.20-rc5
The following changes since commit 651022382c7f8da46cb4872a545ee1da6d097d2a: Linux 4.20-rc1 (2018-11-04 15:37:52 -0800) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git tags/staging-4.20-rc5 for you to fetch changes up to c648284f6c9606f1854816086593eeae5556845a: Merge tag 'iio-fixes-for-4.20a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus (2018-11-22 09:37:36 +0100) Staging and IIO driver fixes for 4.20-rc5 Here are some small IIO and Staging driver fixes for 4.20-rc5. Nothing major, the IIO fix ended up touching the HID drivers at the same time, but the HID maintainer acked it. The staging fixes are all minor patches for reported issues and regressions, full details are in the shortlog. All of these have been in linux-next for a while with no reported issues. Signed-off-by: Greg Kroah-Hartman Ben Wolsieffer (1): staging: vchiq_arm: fix compat VCHIQ_IOC_AWAIT_COMPLETION Christophe JAILLET (1): staging: rtl8723bs: Fix the return value in case of error in 'rtw_wx_read32()' Colin Ian King (3): drivers: staging: cedrus: find ctx before dereferencing it ctx staging: most: use format specifier "%s" in snprintf staging: mt7621-pinctrl: fix uninitialized variable ngroups Greg Kroah-Hartman (1): Merge tag 'iio-fixes-for-4.20a' of git://git.kernel.org/.../jic23/iio into staging-linus Hans de Goede (1): iio/hid-sensors: Fix IIO_CHAN_INFO_RAW returning wrong values for signed numbers Larry Finger (2): staging: rtl8723bs: Fix incorrect sense of ether_addr_equal staging: rtl8723bs: Add missing return for cfg80211_rtw_get_station Martin Kelly (1): iio:st_magn: Fix enable device after trigger Sergio Paracuellos (1): staging: mt7621-dma: fix potentially dereferencing uninitialized 'tx_desc' Spencer E. Olson (2): staging: comedi: ni_mio_common: scale ao INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS staging: comedi: clarify/unify macros for NI macro-defined terminals drivers/hid/hid-sensor-custom.c| 2 +- drivers/hid/hid-sensor-hub.c | 13 ++-- drivers/iio/accel/hid-sensor-accel-3d.c| 5 ++- drivers/iio/gyro/hid-sensor-gyro-3d.c | 5 ++- drivers/iio/humidity/hid-sensor-humidity.c | 3 +- drivers/iio/light/hid-sensor-als.c | 8 +++-- drivers/iio/light/hid-sensor-prox.c| 8 +++-- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 8 +++-- drivers/iio/magnetometer/st_magn_buffer.c | 12 ++- drivers/iio/orientation/hid-sensor-incl-3d.c | 8 +++-- drivers/iio/pressure/hid-sensor-press.c| 8 +++-- drivers/iio/temperature/hid-sensor-temperature.c | 3 +- drivers/rtc/rtc-hid-sensor-time.c | 2 +- drivers/staging/comedi/comedi.h| 39 -- drivers/staging/comedi/drivers/ni_mio_common.c | 3 +- drivers/staging/media/sunxi/cedrus/cedrus.c| 22 ++-- drivers/staging/most/core.c| 2 +- drivers/staging/mt7621-dma/mtk-hsdma.c | 3 +- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c| 2 +- drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 4 +-- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 2 +- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 7 +++- include/linux/hid-sensor-hub.h | 4 ++- 24 files changed, 103 insertions(+), 72 deletions(-) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH] [repost] Drivers: hv: vmbus: Offload the handling of channels to two workqueues
> -Original Message- > From: Dexuan Cui > Sent: Thursday, November 29, 2018 12:17 AM > To: gre...@linuxfoundation.org > Cc: KY Srinivasan ; Haiyang Zhang > ; Stephen Hemminger > ; linux-ker...@vger.kernel.org; > de...@linuxdriverproject.org; a...@canonical.com; vkuznets > ; o...@aepfle.de; jasow...@redhat.com; Michael > Kelley > Subject: RE: [PATCH] [repost] Drivers: hv: vmbus: Offload the handling of > channels to two workqueues > > > From: gre...@linuxfoundation.org > > Sent: Wednesday, November 28, 2018 11:45 PM > > > > > > There is no change in this repost. I just rebased this patch to today's > > > char-misc's char-misc-next branch. Previously KY posted the patch with > his > > > Signed-off-by (which is kept in this repost), but there was a conflict > > > issue. > > > > > > Note: the patch can't be cleanly applied to char-misc's char-misc-linus > branch > > -- > > > to do that, we need to cherry-pick the supporting patch first: > > > 4d3c5c69191f ("Drivers: hv: vmbus: Remove the useless API > > vmbus_get_outgoing_channel()") > > > > That is not going to work for the obvious reason that this dependant > > patch is not going to be merged into 4.20-final. > > It looks the dependent patch (4d3c5c69191f) is going to miss the v4.20 > release. > This is not a big issue, as the dependent patch isn't really important. > > > So, what do you expect us to do here? The only way this can be accepted > > is to have it go into my -next branch, which means it will show up in > > 4.21-rc1, is that ok? > > Is there any chance for this patch ("Drivers: hv: vmbus: Offload the handling > ...") to > go into v4.20? > > If yes, I can quickly do a rebase to char-misc's char-misc-linus branch, > because actually the conflict can be very easily fixed. And I can help to fix > any > conflict when the dependent patch is backported to v4.20.1. This patch fixes an important bug while the patch this depends on is not critical. I suggest we revert the patch that this patch depends on and we can submit a new version of this patch that can go in now - into 4.20 release. K. Y ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFCv2 0/4] mm/memory_hotplug: Introduce memory block types
This is the second approach, introducing more meaningful memory block types and not changing online behavior in the kernel. It is based on latest linux-next. As we found out during dicussion, user space should always handle onlining of memory, in any case. However in order to make smart decisions in user space about if and how to online memory, we have to export more information about memory blocks. This way, we can formulate rules in user space. One such information is the type of memory block we are talking about. This helps to answer some questions like: - Does this memory block belong to a DIMM? - Can this DIMM theoretically ever be unplugged again? - Was this memory added by a balloon driver that will rely on balloon inflation to remove chunks of that memory again? Which zone is advised? - Is this special standby memory on s390x that is usually not automatically onlined? And in short it helps to answer to some extend (excluding zone imbalances) - Should I online this memory block? - To which zone should I online this memory block? ... of course special use cases will result in different anwers. But that's why user space has control of onlining memory. More details can be found in Patch 1 and Patch 3. Tested on x86 with hotplugged DIMMs. Cross-compiled for PPC and s390x. Example: $ udevadm info -q all -a /sys/devices/system/memory/memory0 KERNEL=="memory0" SUBSYSTEM=="memory" DRIVER=="" ATTR{online}=="1" ATTR{phys_device}=="0" ATTR{phys_index}=="" ATTR{removable}=="0" ATTR{state}=="online" ATTR{type}=="boot" ATTR{valid_zones}=="none" $ udevadm info -q all -a /sys/devices/system/memory/memory90 KERNEL=="memory90" SUBSYSTEM=="memory" DRIVER=="" ATTR{online}=="1" ATTR{phys_device}=="0" ATTR{phys_index}=="005a" ATTR{removable}=="1" ATTR{state}=="online" ATTR{type}=="dimm" ATTR{valid_zones}=="Normal" RFC -> RFCv2: - Now also taking care of PPC (somehow missed it :/ ) - Split the series up to some degree (some ideas on how to split up patch 3 would be very welcome) - Introduce more memory block types. Turns out abstracting too much was rather confusing and not helpful. Properly document them. Notes: - I wanted to convert the enum of types into a named enum but this provoked all kinds of different errors. For now, I am doing it just like the other types (e.g. online_type) we are using in that context. - The "removable" property should never have been named like that. It should have been "offlinable". Can we still rename that? E.g. boot memory is sometimes marked as removable ... David Hildenbrand (4): mm/memory_hotplug: Introduce memory block types mm/memory_hotplug: Replace "bool want_memblock" by "int type" mm/memory_hotplug: Introduce and use more memory types mm/memory_hotplug: Drop MEMORY_TYPE_UNSPECIFIED arch/ia64/mm/init.c | 4 +- arch/powerpc/mm/mem.c | 4 +- arch/powerpc/platforms/powernv/memtrace.c | 9 +-- .../platforms/pseries/hotplug-memory.c| 7 +- arch/s390/mm/init.c | 4 +- arch/sh/mm/init.c | 4 +- arch/x86/mm/init_32.c | 4 +- arch/x86/mm/init_64.c | 8 +-- drivers/acpi/acpi_memhotplug.c| 16 - drivers/base/memory.c | 60 ++-- drivers/hv/hv_balloon.c | 3 +- drivers/s390/char/sclp_cmd.c | 3 +- drivers/xen/balloon.c | 2 +- include/linux/memory.h| 69 ++- include/linux/memory_hotplug.h| 18 ++--- kernel/memremap.c | 6 +- mm/memory_hotplug.c | 29 17 files changed, 194 insertions(+), 56 deletions(-) -- 2.17.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFCv2 1/4] mm/memory_hotplug: Introduce memory block types
Memory onlining should always be handled by user space, because only user space knows which use cases it wants to satisfy. E.g. memory might be onlined to the MOVABLE zone even if it can never be removed from the system, e.g. to make usage of huge pages more reliable. However to implement such rules (especially default rules in distributions) we need more information about the memory that was added in user space. E.g. on x86 we want to online memory provided by balloon devices (e.g. XEN, Hyper-V) differently (-> will not be unplugged by offlining the whole block) than ordinary DIMMs (-> might eventually be unplugged by offlining the whole block). This might also become relevat for other architectures. Also, udev rules right now check if running on s390x and treat all added memory blocks as standby memory (-> don't online automatically). As soon as we support other memory hotplug mechanism (e.g. virtio-mem) checks would have to get more involved (e.g. also check if under KVM) but eventually also wrong (e.g. if KVM ever supports standby memory we are doomed). I decided to allow to specify the type of memory that is getting added to the system. Let's start with two types, BOOT and UNSPECIFIED to get the basic infrastructure running. We'll introduce and use further types in follow-up patches. For now we classify any hotplugged memory temporarily as as UNSPECIFIED (which will eventually be dropped later on). Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Andrew Morton Cc: Ingo Molnar Cc: Pavel Tatashin Cc: Stephen Rothwell Cc: Andrew Banman Cc: "mike.tra...@hpe.com" Cc: Oscar Salvador Cc: Dave Hansen Cc: Michal Hocko Cc: Michal Suchánek Cc: Vitaly Kuznetsov Cc: Dan Williams Cc: Pavel Tatashin Cc: Martin Schwidefsky Cc: Heiko Carstens Signed-off-by: David Hildenbrand --- drivers/base/memory.c | 38 +++--- include/linux/memory.h | 27 +++ 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 0c290f86ab20..17f2985c07c5 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -381,6 +381,29 @@ static ssize_t show_phys_device(struct device *dev, return sprintf(buf, "%d\n", mem->phys_device); } +static ssize_t type_show(struct device *dev, struct device_attribute *attr, +char *buf) +{ + struct memory_block *mem = to_memory_block(dev); + ssize_t len = 0; + + switch (mem->type) { + case MEMORY_BLOCK_UNSPECIFIED: + len = sprintf(buf, "unspecified\n"); + break; + case MEMORY_BLOCK_BOOT: + len = sprintf(buf, "boot\n"); + break; + default: + len = sprintf(buf, "ERROR-UNKNOWN-%ld\n", + mem->state); + WARN_ON(1); + break; + } + + return len; +} + #ifdef CONFIG_MEMORY_HOTREMOVE static void print_allowed_zone(char *buf, int nid, unsigned long start_pfn, unsigned long nr_pages, int online_type, @@ -442,6 +465,7 @@ static DEVICE_ATTR(phys_index, 0444, show_mem_start_phys_index, NULL); static DEVICE_ATTR(state, 0644, show_mem_state, store_mem_state); static DEVICE_ATTR(phys_device, 0444, show_phys_device, NULL); static DEVICE_ATTR(removable, 0444, show_mem_removable, NULL); +static DEVICE_ATTR_RO(type); /* * Block size attribute stuff @@ -620,6 +644,7 @@ static struct attribute *memory_memblk_attrs[] = { &dev_attr_state.attr, &dev_attr_phys_device.attr, &dev_attr_removable.attr, + &dev_attr_type.attr, #ifdef CONFIG_MEMORY_HOTREMOVE &dev_attr_valid_zones.attr, #endif @@ -657,13 +682,17 @@ int register_memory(struct memory_block *memory) } static int init_memory_block(struct memory_block **memory, -struct mem_section *section, unsigned long state) +struct mem_section *section, unsigned long state, +int type) { struct memory_block *mem; unsigned long start_pfn; int scn_nr; int ret = 0; + if (type == MEMORY_BLOCK_NONE) + return -EINVAL; + mem = kzalloc(sizeof(*mem), GFP_KERNEL); if (!mem) return -ENOMEM; @@ -675,6 +704,7 @@ static int init_memory_block(struct memory_block **memory, mem->state = state; start_pfn = section_nr_to_pfn(mem->start_section_nr); mem->phys_device = arch_get_memory_phys_device(start_pfn); + mem->type = type; ret = register_memory(mem); @@ -699,7 +729,8 @@ static int add_memory_block(int base_section_nr) if (section_count == 0) return 0; - ret = init_memory_block(&mem, __nr_to_section(section_nr), MEM_ONLINE); + ret = init_memory_block(&mem, __nr_to_section(section_nr), MEM_ONLINE, + MEMORY_BLOCK_BOOT);
[PATCH RFCv2 2/4] mm/memory_hotplug: Replace "bool want_memblock" by "int type"
Let's pass a memory block type instead. Pass "MEMORY_BLOCK_NONE" for device memory and for now "MEMORY_BLOCK_UNSPECIFIED" for anything else. No functional change. Cc: Tony Luck Cc: Fenghua Yu Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: Yoshinori Sato Cc: Rich Felker Cc: Dave Hansen Cc: Andy Lutomirski Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Andrew Morton Cc: Mike Rapoport Cc: Michal Hocko Cc: Dan Williams Cc: "Kirill A. Shutemov" Cc: Oscar Salvador Cc: Nicholas Piggin Cc: Stephen Rothwell Cc: Christophe Leroy Cc: "Jonathan Neuschäfer" Cc: Mauricio Faria de Oliveira Cc: Vasily Gorbik Cc: Arun KS Cc: Rob Herring Cc: Pavel Tatashin Cc: "mike.tra...@hpe.com" Cc: Joonsoo Kim Cc: Wei Yang Cc: Logan Gunthorpe Cc: "Jérôme Glisse" Cc: "Jan H. Schönherr" Cc: Dave Jiang Cc: Matthew Wilcox Cc: Mathieu Malaterre Signed-off-by: David Hildenbrand --- arch/ia64/mm/init.c| 4 ++-- arch/powerpc/mm/mem.c | 4 ++-- arch/s390/mm/init.c| 4 ++-- arch/sh/mm/init.c | 4 ++-- arch/x86/mm/init_32.c | 4 ++-- arch/x86/mm/init_64.c | 8 drivers/base/memory.c | 11 +++ include/linux/memory.h | 2 +- include/linux/memory_hotplug.h | 12 ++-- kernel/memremap.c | 6 -- mm/memory_hotplug.c| 16 11 files changed, 40 insertions(+), 35 deletions(-) diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c index 904fe55e10fc..408635d2902f 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c @@ -646,13 +646,13 @@ mem_init (void) #ifdef CONFIG_MEMORY_HOTPLUG int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, - bool want_memblock) + int type) { unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT; int ret; - ret = __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock); + ret = __add_pages(nid, start_pfn, nr_pages, altmap, type); if (ret) printk("%s: Problem encountered in __add_pages() as ret=%d\n", __func__, ret); diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index b3c9ee5c4f78..e394637da270 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -118,7 +118,7 @@ int __weak remove_section_mapping(unsigned long start, unsigned long end) } int __meminit arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, - bool want_memblock) + int type) { unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT; @@ -135,7 +135,7 @@ int __meminit arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap * } flush_inval_dcache_range(start, start + size); - return __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock); + return __add_pages(nid, start_pfn, nr_pages, altmap, type); } #ifdef CONFIG_MEMORY_HOTREMOVE diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 3e82f66d5c61..ba2c56328e6d 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -225,7 +225,7 @@ device_initcall(s390_cma_mem_init); #endif /* CONFIG_CMA */ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, - bool want_memblock) + int type) { unsigned long start_pfn = PFN_DOWN(start); unsigned long size_pages = PFN_DOWN(size); @@ -235,7 +235,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, if (rc) return rc; - rc = __add_pages(nid, start_pfn, size_pages, altmap, want_memblock); + rc = __add_pages(nid, start_pfn, size_pages, altmap, type); if (rc) vmem_remove_mapping(start, size); return rc; diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index 1a483a008872..5fbb8724e0f2 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -419,14 +419,14 @@ void free_initrd_mem(unsigned long start, unsigned long end) #ifdef CONFIG_MEMORY_HOTPLUG int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, - bool want_memblock) + int type) { unsigned long start_pfn = PFN_DOWN(start); unsigned long nr_pages = size >> PAGE_SHIFT; int ret; /* We only have ZONE_NORMAL, so this is easy.. */ - ret = __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock); + ret = __add_pages(nid, start_pfn, nr_pages, altmap, type); if (unlikely(ret)) printk("%s: Failed, __add_pages() == %d\n", __func__, ret); diff --git a/arch/x86/mm
[PATCH RFCv2 4/4] mm/memory_hotplug: Drop MEMORY_TYPE_UNSPECIFIED
We now have proper types for all users, we can drop this one. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Andrew Morton Cc: Ingo Molnar Cc: Pavel Tatashin Cc: Stephen Rothwell Cc: Andrew Banman Cc: "mike.tra...@hpe.com" Cc: Oscar Salvador Cc: Dave Hansen Cc: Michal Hocko Cc: Michal Suchánek Cc: Vitaly Kuznetsov Cc: Dan Williams Cc: Pavel Tatashin Signed-off-by: David Hildenbrand --- drivers/base/memory.c | 3 --- include/linux/memory.h | 5 - 2 files changed, 8 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index c5fdca7a3009..a6e524f0ea38 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -388,9 +388,6 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr, ssize_t len = 0; switch (mem->type) { - case MEMORY_BLOCK_UNSPECIFIED: - len = sprintf(buf, "unspecified\n"); - break; case MEMORY_BLOCK_BOOT: len = sprintf(buf, "boot\n"); break; diff --git a/include/linux/memory.h b/include/linux/memory.h index a3a1e9764805..11679622f743 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -50,10 +50,6 @@ int set_memory_block_size_order(unsigned int order); * No memory block is to be created (e.g. device memory). Not exposed to * user space. * - * MEMORY_BLOCK_UNSPECIFIED: - * The type of memory block was not further specified when adding the - * memory block. - * * MEMORY_BLOCK_BOOT: * This memory block was added during boot by the basic system. No * specific device driver takes care of this memory block. This memory @@ -103,7 +99,6 @@ int set_memory_block_size_order(unsigned int order); */ enum { MEMORY_BLOCK_NONE = 0, - MEMORY_BLOCK_UNSPECIFIED, MEMORY_BLOCK_BOOT, MEMORY_BLOCK_DIMM, MEMORY_BLOCK_DIMM_UNREMOVABLE, -- 2.17.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RFCv2 3/4] mm/memory_hotplug: Introduce and use more memory types
Let's introduce new types for different kinds of memory blocks and use them in existing code. As I don't see an easy way to split this up, do it in one hunk for now. acpi: Use DIMM or DIMM_UNREMOVABLE depending on hotremove support in the kernel. Properly change the type when trying to add memory that was already detected and used during boot (so this memory will correctly end up as "acpi" in user space). pseries: Use DIMM or DIMM_UNREMOVABLE depending on hotremove support in the kernel. As far as I see, handling like in the acpi case for existing blocks is not required. probed memory from user space: Use DIMM_UNREMOVABLE as there is no interface to get rid of this code again. hv_balloon,xen/balloon: Use BALLOON. As simple as that :) s390x/sclp: Use a dedicated type S390X_STANDBY as this type of memory and it's semantics are very s390x specific. powernv/memtrace: Only allow to use BOOT memory for memtrace. I consider this code in general dangerous, but we have to keep it working ... most probably just a debug feature. Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: Greg Kroah-Hartman Cc: "K. Y. Srinivasan" Cc: Haiyang Zhang Cc: Stephen Hemminger Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: Boris Ostrovsky Cc: Juergen Gross Cc: Stefano Stabellini Cc: Rashmica Gupta Cc: Andrew Morton Cc: Pavel Tatashin Cc: Balbir Singh Cc: Michael Neuling Cc: Nathan Fontenot Cc: YueHaibing Cc: Vasily Gorbik Cc: Ingo Molnar Cc: Stephen Rothwell Cc: "mike.tra...@hpe.com" Cc: Oscar Salvador Cc: Joonsoo Kim Cc: Mathieu Malaterre Cc: Michal Hocko Cc: Arun KS Cc: Andrew Banman Cc: Dave Hansen Cc: Michal Suchánek Cc: Vitaly Kuznetsov Cc: Dan Williams Signed-off-by: David Hildenbrand --- At first I tried to abstract the types quite a lot, but I think there are subtle differences that are worth differentiating. More details about the types can be found in the excessive documentation. It is wort noting that BALLOON_MOVABLE has no user yet, but I have something in mind that might want to make use of that (virtio-mem). Just included it to discuss the general approach. I can drop it from this patch. --- arch/powerpc/platforms/powernv/memtrace.c | 9 ++-- .../platforms/pseries/hotplug-memory.c| 7 ++- drivers/acpi/acpi_memhotplug.c| 16 ++- drivers/base/memory.c | 18 ++- drivers/hv/hv_balloon.c | 3 +- drivers/s390/char/sclp_cmd.c | 3 +- drivers/xen/balloon.c | 2 +- include/linux/memory.h| 47 ++- include/linux/memory_hotplug.h| 6 +-- mm/memory_hotplug.c | 15 +++--- 10 files changed, 104 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c index 248a38ad25c7..5d08db87091e 100644 --- a/arch/powerpc/platforms/powernv/memtrace.c +++ b/arch/powerpc/platforms/powernv/memtrace.c @@ -54,9 +54,9 @@ static const struct file_operations memtrace_fops = { .open = simple_open, }; -static int check_memblock_online(struct memory_block *mem, void *arg) +static int check_memblock_boot_and_online(struct memory_block *mem, void *arg) { - if (mem->state != MEM_ONLINE) + if (mem->type != MEM_BLOCK_BOOT || mem->state != MEM_ONLINE) return -1; return 0; @@ -77,7 +77,7 @@ static bool memtrace_offline_pages(u32 nid, u64 start_pfn, u64 nr_pages) u64 end_pfn = start_pfn + nr_pages - 1; if (walk_memory_range(start_pfn, end_pfn, NULL, - check_memblock_online)) + check_memblock_boot_and_online)) return false; walk_memory_range(start_pfn, end_pfn, (void *)MEM_GOING_OFFLINE, @@ -233,7 +233,8 @@ static int memtrace_online(void) ent->mem = 0; } - if (add_memory(ent->nid, ent->start, ent->size)) { + if (add_memory(ent->nid, ent->start, ent->size, + MEMORY_BLOCK_BOOT)) { pr_err("Failed to add trace memory to node %d\n", ent->nid); ret += 1; diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 2a983b5a52e1..5f91359c7993 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -651,7 +651,7 @@ static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index) static int dlpar_add_lmb(struct drmem_lmb *lmb) { unsigned long block_sz; - int nid, rc; + int nid, rc, type = MEMORY_BLOCK_DIMM; if (lmb->flags & DRCONF_MEM_ASSIGNED) return -EINVAL; @@ -667,8 +667,11 @@ static int dlpar_add_lmb(struct drmem_
RE: [PATCH] [repost] Drivers: hv: vmbus: Offload the handling of channels to two workqueues
> From: KY Srinivasan > Sent: Friday, November 30, 2018 9:31 AM > > From: Dexuan Cui > > Sent: Thursday, November 29, 2018 12:17 AM > > To: gre...@linuxfoundation.org > > Cc: KY Srinivasan ; Haiyang Zhang > > ; Stephen Hemminger > > ; linux-ker...@vger.kernel.org; > > de...@linuxdriverproject.org; a...@canonical.com; vkuznets > > ; o...@aepfle.de; jasow...@redhat.com; Michael > > Kelley > > Subject: RE: [PATCH] [repost] Drivers: hv: vmbus: Offload the handling of > > channels to two workqueues > > > > > From: gre...@linuxfoundation.org > > > Sent: Wednesday, November 28, 2018 11:45 PM > > > > > > > > There is no change in this repost. I just rebased this patch to today's > > > > char-misc's char-misc-next branch. Previously KY posted the patch with > > his > > > > Signed-off-by (which is kept in this repost), but there was a conflict > > > > issue. > > > > > > > > Note: the patch can't be cleanly applied to char-misc's char-misc-linus > > branch > > > -- > > > > to do that, we need to cherry-pick the supporting patch first: > > > > 4d3c5c69191f ("Drivers: hv: vmbus: Remove the useless API > > > vmbus_get_outgoing_channel()") > > > > > > That is not going to work for the obvious reason that this dependant > > > patch is not going to be merged into 4.20-final. > > > > It looks the dependent patch (4d3c5c69191f) is going to miss the v4.20 > > release. > > This is not a big issue, as the dependent patch isn't really important. > > > > > So, what do you expect us to do here? The only way this can be accepted > > > is to have it go into my -next branch, which means it will show up in > > > 4.21-rc1, is that ok? > > > > Is there any chance for this patch ("Drivers: hv: vmbus: Offload the > > handling > > ...") to > > go into v4.20? > > > > If yes, I can quickly do a rebase to char-misc's char-misc-linus branch, > > because actually the conflict can be very easily fixed. And I can help to > > fix any > > conflict when the dependent patch is backported to v4.20.1. > > This patch fixes an important bug while the patch this depends on is not > critical. > I suggest we revert the patch that this patch depends on > and we can submit a new version of this patch that can go in now - into 4.20 > release. > > K. Y I agree. Hi Greg, Please let us know what we can do to try to push this important fix into v4.20. Actually it's straightforward, though it looks big. And, we ave done a full testing with the patch. Thanks, --Dexuan ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [GIT PULL] Staging/IIO driver fixes for 4.20-rc5
The pull request you sent on Fri, 30 Nov 2018 17:04:57 +0100: > git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git > tags/staging-4.20-rc5 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/cd9a0433238da43611179e44b1d71ad24998b107 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH RFCv2 0/4] mm/memory_hotplug: Introduce memory block types
On Fri, Nov 30, 2018 at 06:59:18PM +0100, David Hildenbrand wrote: >This is the second approach, introducing more meaningful memory block >types and not changing online behavior in the kernel. It is based on >latest linux-next. > >As we found out during dicussion, user space should always handle onlining >of memory, in any case. However in order to make smart decisions in user >space about if and how to online memory, we have to export more information >about memory blocks. This way, we can formulate rules in user space. > >One such information is the type of memory block we are talking about. >This helps to answer some questions like: >- Does this memory block belong to a DIMM? >- Can this DIMM theoretically ever be unplugged again? >- Was this memory added by a balloon driver that will rely on balloon > inflation to remove chunks of that memory again? Which zone is advised? >- Is this special standby memory on s390x that is usually not automatically > onlined? > >And in short it helps to answer to some extend (excluding zone imbalances) >- Should I online this memory block? >- To which zone should I online this memory block? >... of course special use cases will result in different anwers. But that's >why user space has control of onlining memory. > >More details can be found in Patch 1 and Patch 3. >Tested on x86 with hotplugged DIMMs. Cross-compiled for PPC and s390x. > > >Example: >$ udevadm info -q all -a /sys/devices/system/memory/memory0 > KERNEL=="memory0" > SUBSYSTEM=="memory" > DRIVER=="" > ATTR{online}=="1" > ATTR{phys_device}=="0" > ATTR{phys_index}=="" > ATTR{removable}=="0" > ATTR{state}=="online" > ATTR{type}=="boot" > ATTR{valid_zones}=="none" >$ udevadm info -q all -a /sys/devices/system/memory/memory90 > KERNEL=="memory90" > SUBSYSTEM=="memory" > DRIVER=="" > ATTR{online}=="1" > ATTR{phys_device}=="0" > ATTR{phys_index}=="005a" > ATTR{removable}=="1" > ATTR{state}=="online" > ATTR{type}=="dimm" > ATTR{valid_zones}=="Normal" > > >RFC -> RFCv2: >- Now also taking care of PPC (somehow missed it :/ ) >- Split the series up to some degree (some ideas on how to split up patch 3 > would be very welcome) >- Introduce more memory block types. Turns out abstracting too much was > rather confusing and not helpful. Properly document them. > >Notes: >- I wanted to convert the enum of types into a named enum but this > provoked all kinds of different errors. For now, I am doing it just like > the other types (e.g. online_type) we are using in that context. >- The "removable" property should never have been named like that. It > should have been "offlinable". Can we still rename that? E.g. boot memory > is sometimes marked as removable ... > This make sense to me. Remove usually describe physical hotplug phase, if I am correct. -- Wei Yang Help you, Help me ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH RFCv2 1/4] mm/memory_hotplug: Introduce memory block types
On Fri, Nov 30, 2018 at 06:59:19PM +0100, David Hildenbrand wrote: >Memory onlining should always be handled by user space, because only user >space knows which use cases it wants to satisfy. E.g. memory might be >onlined to the MOVABLE zone even if it can never be removed from the >system, e.g. to make usage of huge pages more reliable. > >However to implement such rules (especially default rules in distributions) >we need more information about the memory that was added in user space. > >E.g. on x86 we want to online memory provided by balloon devices (e.g. >XEN, Hyper-V) differently (-> will not be unplugged by offlining the whole >block) than ordinary DIMMs (-> might eventually be unplugged by offlining >the whole block). This might also become relevat for other architectures. > >Also, udev rules right now check if running on s390x and treat all added >memory blocks as standby memory (-> don't online automatically). As soon as >we support other memory hotplug mechanism (e.g. virtio-mem) checks would >have to get more involved (e.g. also check if under KVM) but eventually >also wrong (e.g. if KVM ever supports standby memory we are doomed). > >I decided to allow to specify the type of memory that is getting added >to the system. Let's start with two types, BOOT and UNSPECIFIED to get the >basic infrastructure running. We'll introduce and use further types in >follow-up patches. For now we classify any hotplugged memory temporarily >as as UNSPECIFIED (which will eventually be dropped later on). > >Cc: Greg Kroah-Hartman >Cc: "Rafael J. Wysocki" >Cc: Andrew Morton >Cc: Ingo Molnar >Cc: Pavel Tatashin >Cc: Stephen Rothwell >Cc: Andrew Banman >Cc: "mike.tra...@hpe.com" >Cc: Oscar Salvador >Cc: Dave Hansen >Cc: Michal Hocko >Cc: Michal Such??nek >Cc: Vitaly Kuznetsov >Cc: Dan Williams >Cc: Pavel Tatashin >Cc: Martin Schwidefsky >Cc: Heiko Carstens >Signed-off-by: David Hildenbrand >--- > drivers/base/memory.c | 38 +++--- > include/linux/memory.h | 27 +++ > 2 files changed, 62 insertions(+), 3 deletions(-) > >diff --git a/drivers/base/memory.c b/drivers/base/memory.c >index 0c290f86ab20..17f2985c07c5 100644 >--- a/drivers/base/memory.c >+++ b/drivers/base/memory.c >@@ -381,6 +381,29 @@ static ssize_t show_phys_device(struct device *dev, > return sprintf(buf, "%d\n", mem->phys_device); > } > >+static ssize_t type_show(struct device *dev, struct device_attribute *attr, >+ char *buf) >+{ >+ struct memory_block *mem = to_memory_block(dev); >+ ssize_t len = 0; >+ >+ switch (mem->type) { >+ case MEMORY_BLOCK_UNSPECIFIED: >+ len = sprintf(buf, "unspecified\n"); >+ break; >+ case MEMORY_BLOCK_BOOT: >+ len = sprintf(buf, "boot\n"); >+ break; >+ default: >+ len = sprintf(buf, "ERROR-UNKNOWN-%ld\n", >+ mem->state); >+ WARN_ON(1); >+ break; >+ } >+ >+ return len; >+} >+ > #ifdef CONFIG_MEMORY_HOTREMOVE > static void print_allowed_zone(char *buf, int nid, unsigned long start_pfn, > unsigned long nr_pages, int online_type, >@@ -442,6 +465,7 @@ static DEVICE_ATTR(phys_index, 0444, >show_mem_start_phys_index, NULL); > static DEVICE_ATTR(state, 0644, show_mem_state, store_mem_state); > static DEVICE_ATTR(phys_device, 0444, show_phys_device, NULL); > static DEVICE_ATTR(removable, 0444, show_mem_removable, NULL); >+static DEVICE_ATTR_RO(type); This is correct, while looks not consistent with other attributes. Not that beautiful :-) > > /* > * Block size attribute stuff >@@ -620,6 +644,7 @@ static struct attribute *memory_memblk_attrs[] = { > &dev_attr_state.attr, > &dev_attr_phys_device.attr, > &dev_attr_removable.attr, >+ &dev_attr_type.attr, > #ifdef CONFIG_MEMORY_HOTREMOVE > &dev_attr_valid_zones.attr, > #endif >@@ -657,13 +682,17 @@ int register_memory(struct memory_block *memory) > } > > static int init_memory_block(struct memory_block **memory, >- struct mem_section *section, unsigned long state) >+ struct mem_section *section, unsigned long state, >+ int type) > { > struct memory_block *mem; > unsigned long start_pfn; > int scn_nr; > int ret = 0; > >+ if (type == MEMORY_BLOCK_NONE) >+ return -EINVAL; No one will pass in this value. Can we omit this check for now? >+ > mem = kzalloc(sizeof(*mem), GFP_KERNEL); > if (!mem) > return -ENOMEM; >@@ -675,6 +704,7 @@ static int init_memory_block(struct memory_block **memory, > mem->state = state; > start_pfn = section_nr_to_pfn(mem->start_section_nr); > mem->phys_device = arch_get_memory_phys_device(start_pfn); >+ mem->type = type; > > ret = register_memory(mem); > >@@ -699,7 +729,8 @@ static in
[PATCH] binder: remove BINDER_DEBUG_ENTRY()
We already have the DEFINE_SHOW_ATTRIBUTE.There is no need to define such a macro,so remove BINDER_DEBUG_ENTRY. Signed-off-by: Yangtao Li --- drivers/android/binder.c | 48 ++-- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index cb30a524d16d..5496b8e07234 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -94,22 +94,8 @@ static struct dentry *binder_debugfs_dir_entry_root; static struct dentry *binder_debugfs_dir_entry_proc; static atomic_t binder_last_id; -#define BINDER_DEBUG_ENTRY(name) \ -static int binder_##name##_open(struct inode *inode, struct file *file) \ -{ \ - return single_open(file, binder_##name##_show, inode->i_private); \ -} \ -\ -static const struct file_operations binder_##name##_fops = { \ - .owner = THIS_MODULE, \ - .open = binder_##name##_open, \ - .read = seq_read, \ - .llseek = seq_lseek, \ - .release = single_release, \ -} - -static int binder_proc_show(struct seq_file *m, void *unused); -BINDER_DEBUG_ENTRY(proc); +static int proc_show(struct seq_file *m, void *unused); +DEFINE_SHOW_ATTRIBUTE(proc); /* This is only defined in include/asm-arm/sizes.h */ #ifndef SZ_1K @@ -4964,7 +4950,7 @@ static int binder_open(struct inode *nodp, struct file *filp) proc->debugfs_entry = debugfs_create_file(strbuf, 0444, binder_debugfs_dir_entry_proc, (void *)(unsigned long)proc->pid, - &binder_proc_fops); + &proc_fops); } return 0; @@ -5592,7 +5578,7 @@ static void print_binder_proc_stats(struct seq_file *m, } -static int binder_state_show(struct seq_file *m, void *unused) +static int state_show(struct seq_file *m, void *unused) { struct binder_proc *proc; struct binder_node *node; @@ -5631,7 +5617,7 @@ static int binder_state_show(struct seq_file *m, void *unused) return 0; } -static int binder_stats_show(struct seq_file *m, void *unused) +static int stats_show(struct seq_file *m, void *unused) { struct binder_proc *proc; @@ -5647,7 +5633,7 @@ static int binder_stats_show(struct seq_file *m, void *unused) return 0; } -static int binder_transactions_show(struct seq_file *m, void *unused) +static int transactions_show(struct seq_file *m, void *unused) { struct binder_proc *proc; @@ -5660,7 +5646,7 @@ static int binder_transactions_show(struct seq_file *m, void *unused) return 0; } -static int binder_proc_show(struct seq_file *m, void *unused) +static int proc_show(struct seq_file *m, void *unused) { struct binder_proc *itr; int pid = (unsigned long)m->private; @@ -5703,7 +5689,7 @@ static void print_binder_transaction_log_entry(struct seq_file *m, "\n" : " (incomplete)\n"); } -static int binder_transaction_log_show(struct seq_file *m, void *unused) +static int transaction_log_show(struct seq_file *m, void *unused) { struct binder_transaction_log *log = m->private; unsigned int log_cur = atomic_read(&log->cur); @@ -5735,10 +5721,10 @@ static const struct file_operations binder_fops = { .release = binder_release, }; -BINDER_DEBUG_ENTRY(state); -BINDER_DEBUG_ENTRY(stats); -BINDER_DEBUG_ENTRY(transactions); -BINDER_DEBUG_ENTRY(transaction_log); +DEFINE_SHOW_ATTRIBUTE(state); +DEFINE_SHOW_ATTRIBUTE(stats); +DEFINE_SHOW_ATTRIBUTE(transactions); +DEFINE_SHOW_ATTRIBUTE(transaction_log); static int __init init_binder_device(const char *name) { @@ -5792,27 +5778,27 @@ static int __init binder_init(void) 0444, binder_debugfs_dir_entry_root, NULL, - &binder_state_fops); + &state_fops); debugfs_create_file("stats", 0444, binder_debugfs_dir_entry_root, NULL, - &binder_stats_fops); + &stats_fops); debugfs_create_file("transactions", 0444, binder_debugfs_dir_entry_root, NULL, - &binder_transactions_fops); + &transactions_fops); debugfs_create_file("transaction_log", 0444, binder_debugfs_dir_entry_root, &binder_transaction_log, - &binder_transaction_log_fops); + &transaction_log_fops); debugfs_create_file("failed
Re: [PATCH] binder: remove BINDER_DEBUG_ENTRY()
On Fri, Nov 30, 2018 at 08:26:30PM -0500, Yangtao Li wrote: > We already have the DEFINE_SHOW_ATTRIBUTE.There is no need to define > such a macro,so remove BINDER_DEBUG_ENTRY. > > Signed-off-by: Yangtao Li Good catch. Reviewed-by: Joey Pabalinas On Fri, Nov 30, 2018 at 08:26:30PM -0500, Yangtao Li wrote: > We already have the DEFINE_SHOW_ATTRIBUTE.There is no need to define > such a macro,so remove BINDER_DEBUG_ENTRY. > > Signed-off-by: Yangtao Li > --- > drivers/android/binder.c | 48 ++-- > 1 file changed, 17 insertions(+), 31 deletions(-) > > diff --git a/drivers/android/binder.c b/drivers/android/binder.c > index cb30a524d16d..5496b8e07234 100644 > --- a/drivers/android/binder.c > +++ b/drivers/android/binder.c > @@ -94,22 +94,8 @@ static struct dentry *binder_debugfs_dir_entry_root; > static struct dentry *binder_debugfs_dir_entry_proc; > static atomic_t binder_last_id; > > -#define BINDER_DEBUG_ENTRY(name) \ > -static int binder_##name##_open(struct inode *inode, struct file *file) \ > -{ \ > - return single_open(file, binder_##name##_show, inode->i_private); \ > -} \ > -\ > -static const struct file_operations binder_##name##_fops = { \ > - .owner = THIS_MODULE, \ > - .open = binder_##name##_open, \ > - .read = seq_read, \ > - .llseek = seq_lseek, \ > - .release = single_release, \ > -} > - > -static int binder_proc_show(struct seq_file *m, void *unused); > -BINDER_DEBUG_ENTRY(proc); > +static int proc_show(struct seq_file *m, void *unused); > +DEFINE_SHOW_ATTRIBUTE(proc); > > /* This is only defined in include/asm-arm/sizes.h */ > #ifndef SZ_1K > @@ -4964,7 +4950,7 @@ static int binder_open(struct inode *nodp, struct file > *filp) > proc->debugfs_entry = debugfs_create_file(strbuf, 0444, > binder_debugfs_dir_entry_proc, > (void *)(unsigned long)proc->pid, > - &binder_proc_fops); > + &proc_fops); > } > > return 0; > @@ -5592,7 +5578,7 @@ static void print_binder_proc_stats(struct seq_file *m, > } > > > -static int binder_state_show(struct seq_file *m, void *unused) > +static int state_show(struct seq_file *m, void *unused) > { > struct binder_proc *proc; > struct binder_node *node; > @@ -5631,7 +5617,7 @@ static int binder_state_show(struct seq_file *m, void > *unused) > return 0; > } > > -static int binder_stats_show(struct seq_file *m, void *unused) > +static int stats_show(struct seq_file *m, void *unused) > { > struct binder_proc *proc; > > @@ -5647,7 +5633,7 @@ static int binder_stats_show(struct seq_file *m, void > *unused) > return 0; > } > > -static int binder_transactions_show(struct seq_file *m, void *unused) > +static int transactions_show(struct seq_file *m, void *unused) > { > struct binder_proc *proc; > > @@ -5660,7 +5646,7 @@ static int binder_transactions_show(struct seq_file *m, > void *unused) > return 0; > } > > -static int binder_proc_show(struct seq_file *m, void *unused) > +static int proc_show(struct seq_file *m, void *unused) > { > struct binder_proc *itr; > int pid = (unsigned long)m->private; > @@ -5703,7 +5689,7 @@ static void print_binder_transaction_log_entry(struct > seq_file *m, > "\n" : " (incomplete)\n"); > } > > -static int binder_transaction_log_show(struct seq_file *m, void *unused) > +static int transaction_log_show(struct seq_file *m, void *unused) > { > struct binder_transaction_log *log = m->private; > unsigned int log_cur = atomic_read(&log->cur); > @@ -5735,10 +5721,10 @@ static const struct file_operations binder_fops = { > .release = binder_release, > }; > > -BINDER_DEBUG_ENTRY(state); > -BINDER_DEBUG_ENTRY(stats); > -BINDER_DEBUG_ENTRY(transactions); > -BINDER_DEBUG_ENTRY(transaction_log); > +DEFINE_SHOW_ATTRIBUTE(state); > +DEFINE_SHOW_ATTRIBUTE(stats); > +DEFINE_SHOW_ATTRIBUTE(transactions); > +DEFINE_SHOW_ATTRIBUTE(transaction_log); > > static int __init init_binder_device(const char *name) > { > @@ -5792,27 +5778,27 @@ static int __init binder_init(void) > 0444, > binder_debugfs_dir_entry_root, > NULL, > - &binder_state_fops); > + &state_fops); > debugfs_create_file("stats", > 0444, > binder_debugfs_dir_entry_root, > NULL, > - &binder_stats_fops); > + &stats_fops); > debugfs_create_file("transactions", > 0444, > binder_debugfs_dir_entry_root, > NULL, > -
Re: [PATCH RFCv2 2/4] mm/memory_hotplug: Replace "bool want_memblock" by "int type"
On Fri, Nov 30, 2018 at 06:59:20PM +0100, David Hildenbrand wrote: >Let's pass a memory block type instead. Pass "MEMORY_BLOCK_NONE" for device >memory and for now "MEMORY_BLOCK_UNSPECIFIED" for anything else. No >functional change. I would suggest to put more words to this. " Function arch_add_memory()'s last parameter *want_memblock* is used to determin whether it is necessary to create a corresponding memory block device. After introducing the memory block type, this patch replaces the bool type *want_memblock* with memory block type with following rules for now: * Pass "MEMORY_BLOCK_NONE" for device memory * Pass "MEMORY_BLOCK_UNSPECIFIED" for anything else Since this parameter is passed deep to __add_section(), all its descendents are effected. Below lists those descendents. arch_add_memory() add_pages() __add_pages() __add_section() " > >Cc: Tony Luck >Cc: Fenghua Yu >Cc: Benjamin Herrenschmidt >Cc: Paul Mackerras >Cc: Michael Ellerman >Cc: Martin Schwidefsky >Cc: Heiko Carstens >Cc: Yoshinori Sato >Cc: Rich Felker >Cc: Dave Hansen >Cc: Andy Lutomirski >Cc: Peter Zijlstra >Cc: Thomas Gleixner >Cc: Ingo Molnar >Cc: Borislav Petkov >Cc: "H. Peter Anvin" >Cc: x...@kernel.org >Cc: Greg Kroah-Hartman >Cc: "Rafael J. Wysocki" >Cc: Andrew Morton >Cc: Mike Rapoport >Cc: Michal Hocko >Cc: Dan Williams >Cc: "Kirill A. Shutemov" >Cc: Oscar Salvador >Cc: Nicholas Piggin >Cc: Stephen Rothwell >Cc: Christophe Leroy >Cc: "Jonathan Neusch??fer" >Cc: Mauricio Faria de Oliveira >Cc: Vasily Gorbik >Cc: Arun KS >Cc: Rob Herring >Cc: Pavel Tatashin >Cc: "mike.tra...@hpe.com" >Cc: Joonsoo Kim >Cc: Wei Yang >Cc: Logan Gunthorpe >Cc: "J??r??me Glisse" >Cc: "Jan H. Sch??nherr" >Cc: Dave Jiang >Cc: Matthew Wilcox >Cc: Mathieu Malaterre >Signed-off-by: David Hildenbrand >--- > arch/ia64/mm/init.c| 4 ++-- > arch/powerpc/mm/mem.c | 4 ++-- > arch/s390/mm/init.c| 4 ++-- > arch/sh/mm/init.c | 4 ++-- > arch/x86/mm/init_32.c | 4 ++-- > arch/x86/mm/init_64.c | 8 > drivers/base/memory.c | 11 +++ > include/linux/memory.h | 2 +- > include/linux/memory_hotplug.h | 12 ++-- > kernel/memremap.c | 6 -- > mm/memory_hotplug.c| 16 > 11 files changed, 40 insertions(+), 35 deletions(-) > >diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c >index 904fe55e10fc..408635d2902f 100644 >--- a/arch/ia64/mm/init.c >+++ b/arch/ia64/mm/init.c >@@ -646,13 +646,13 @@ mem_init (void) > > #ifdef CONFIG_MEMORY_HOTPLUG > int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, >- bool want_memblock) >+ int type) > { > unsigned long start_pfn = start >> PAGE_SHIFT; > unsigned long nr_pages = size >> PAGE_SHIFT; > int ret; > >- ret = __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock); >+ ret = __add_pages(nid, start_pfn, nr_pages, altmap, type); > if (ret) > printk("%s: Problem encountered in __add_pages() as ret=%d\n", > __func__, ret); >diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c >index b3c9ee5c4f78..e394637da270 100644 >--- a/arch/powerpc/mm/mem.c >+++ b/arch/powerpc/mm/mem.c >@@ -118,7 +118,7 @@ int __weak remove_section_mapping(unsigned long start, >unsigned long end) > } > > int __meminit arch_add_memory(int nid, u64 start, u64 size, struct > vmem_altmap *altmap, >- bool want_memblock) >+int type) > { > unsigned long start_pfn = start >> PAGE_SHIFT; > unsigned long nr_pages = size >> PAGE_SHIFT; >@@ -135,7 +135,7 @@ int __meminit arch_add_memory(int nid, u64 start, u64 >size, struct vmem_altmap * > } > flush_inval_dcache_range(start, start + size); > >- return __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock); >+ return __add_pages(nid, start_pfn, nr_pages, altmap, type); > } > > #ifdef CONFIG_MEMORY_HOTREMOVE >diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c >index 3e82f66d5c61..ba2c56328e6d 100644 >--- a/arch/s390/mm/init.c >+++ b/arch/s390/mm/init.c >@@ -225,7 +225,7 @@ device_initcall(s390_cma_mem_init); > #endif /* CONFIG_CMA */ > > int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, >- bool want_memblock) >+ int type) > { > unsigned long start_pfn = PFN_DOWN(start); > unsigned long size_pages = PFN_DOWN(size); >@@ -235,7 +235,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct >vmem_altmap *altmap, > if (rc) > return rc; > >- rc = __add_pages(nid, start_pfn, size_pages, altmap, want_memblock); >+ rc = __add_pages(nid, start_pfn, size_pages, altmap, type); > if (rc) > vmem_remove_mapping(start, size); > return rc; >diff --git a/arch/sh/mm/init.c