* Re: [PATCH v3 03/20] exec: Let qemu_ram_*() functions take a const pointer argument
From: Philippe Mathieu-Daudé @ 2020-02-20 13:23 UTC (permalink / raw)
To: Paolo Bonzini, Peter Maydell, qemu-devel
Cc: Edgar E. Iglesias, Anthony Perard, Fam Zheng,
Hervé Poussineau, kvm, Laurent Vivier, Thomas Huth,
Stefan Weil, Eric Auger, Halil Pasic, Marcel Apfelbaum,
qemu-s390x, Aleksandar Rikalo, David Gibson, Michael Walle,
qemu-ppc, Gerd Hoffmann, Cornelia Huck, qemu-arm,
Alistair Francis, qemu-block, Cédric Le Goater, Jason Wang,
xen-devel, Christian Borntraeger, Dmitry Fleytman, Matthew Rosato,
Eduardo Habkost, Richard Henderson, Michael S. Tsirkin,
David Hildenbrand, Stefano Stabellini, Igor Mitsyanko,
Paul Durrant, Richard Henderson, John Snow
In-Reply-To: <fce0956e-e542-e8a5-bd02-a7941a9db627@redhat.com>
On 2/20/20 2:21 PM, Paolo Bonzini wrote:
> On 20/02/20 14:05, Philippe Mathieu-Daudé wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> include/exec/cpu-common.h | 6 +++---
>> include/sysemu/xen-mapcache.h | 4 ++--
>> exec.c | 8 ++++----
>> hw/i386/xen/xen-mapcache.c | 2 +-
>> 4 files changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
>> index 81753bbb34..05ac1a5d69 100644
>> --- a/include/exec/cpu-common.h
>> +++ b/include/exec/cpu-common.h
>> @@ -48,11 +48,11 @@ typedef uint32_t CPUReadMemoryFunc(void *opaque, hwaddr addr);
>>
>> void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
>> /* This should not be used by devices. */
>> -ram_addr_t qemu_ram_addr_from_host(void *ptr);
>> +ram_addr_t qemu_ram_addr_from_host(const void *ptr);
>
> This is a bit ugly, because the pointer _can_ be modified via
> qemu_map_ram_ptr.
OK.
> Is this needed for the rest of the series to apply?
No!
> Paolo
>
>> RAMBlock *qemu_ram_block_by_name(const char *name);
>> -RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
>> +RAMBlock *qemu_ram_block_from_host(const void *ptr, bool round_offset,
>> ram_addr_t *offset);
>> -ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host);
>> +ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, const void *host);
>> void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
>> void qemu_ram_unset_idstr(RAMBlock *block);
>> const char *qemu_ram_get_idstr(RAMBlock *rb);
>> diff --git a/include/sysemu/xen-mapcache.h b/include/sysemu/xen-mapcache.h
>> index c8e7c2f6cf..81e9aa2fa6 100644
>> --- a/include/sysemu/xen-mapcache.h
>> +++ b/include/sysemu/xen-mapcache.h
>> @@ -19,7 +19,7 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f,
>> void *opaque);
>> uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size,
>> uint8_t lock, bool dma);
>> -ram_addr_t xen_ram_addr_from_mapcache(void *ptr);
>> +ram_addr_t xen_ram_addr_from_mapcache(const void *ptr);
>> void xen_invalidate_map_cache_entry(uint8_t *buffer);
>> void xen_invalidate_map_cache(void);
>> uint8_t *xen_replace_cache_entry(hwaddr old_phys_addr,
>> @@ -40,7 +40,7 @@ static inline uint8_t *xen_map_cache(hwaddr phys_addr,
>> abort();
>> }
>>
>> -static inline ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
>> +static inline ram_addr_t xen_ram_addr_from_mapcache(const void *ptr)
>> {
>> abort();
>> }
>> diff --git a/exec.c b/exec.c
>> index 8e9cc3b47c..02b4e6ea41 100644
>> --- a/exec.c
>> +++ b/exec.c
>> @@ -2614,7 +2614,7 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr,
>> }
>>
>> /* Return the offset of a hostpointer within a ramblock */
>> -ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host)
>> +ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, const void *host)
>> {
>> ram_addr_t res = (uint8_t *)host - (uint8_t *)rb->host;
>> assert((uintptr_t)host >= (uintptr_t)rb->host);
>> @@ -2640,11 +2640,11 @@ ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host)
>> * pointer, such as a reference to the region that includes the incoming
>> * ram_addr_t.
>> */
>> -RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
>> +RAMBlock *qemu_ram_block_from_host(const void *ptr, bool round_offset,
>> ram_addr_t *offset)
>> {
>> RAMBlock *block;
>> - uint8_t *host = ptr;
>> + const uint8_t *host = ptr;
>>
>> if (xen_enabled()) {
>> ram_addr_t ram_addr;
>> @@ -2705,7 +2705,7 @@ RAMBlock *qemu_ram_block_by_name(const char *name)
>>
>> /* Some of the softmmu routines need to translate from a host pointer
>> (typically a TLB entry) back to a ram offset. */
>> -ram_addr_t qemu_ram_addr_from_host(void *ptr)
>> +ram_addr_t qemu_ram_addr_from_host(const void *ptr)
>> {
>> RAMBlock *block;
>> ram_addr_t offset;
>> diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c
>> index 5b120ed44b..432ad3354d 100644
>> --- a/hw/i386/xen/xen-mapcache.c
>> +++ b/hw/i386/xen/xen-mapcache.c
>> @@ -363,7 +363,7 @@ uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size,
>> return p;
>> }
>>
>> -ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
>> +ram_addr_t xen_ram_addr_from_mapcache(const void *ptr)
>> {
>> MapCacheEntry *entry = NULL;
>> MapCacheRev *reventry;
>>
>
^ permalink raw reply
* [PATCH] USB: Replace zero-length array with flexible-array member
From: Gustavo A. R. Silva @ 2020-02-20 13:20 UTC (permalink / raw)
To: Greg Kroah-Hartman, Minas Harutyunyan, Alan Stern, Thierry Reding,
Jonathan Hunter, Mathias Nyman, Matthias Brugger, Johan Hovold,
Felipe Balbi
Cc: Gustavo A. R. Silva, linux-usb, linux-kernel, linux-mediatek,
linux-tegra, linux-arm-kernel
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:
struct foo {
int stuff;
struct boo array[];
};
By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.
Also, notice that, dynamic memory allocations won't be affected by
this change:
"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]
This issue was found with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/usb/atm/usbatm.h | 2 +-
drivers/usb/dwc2/hcd.h | 2 +-
drivers/usb/host/ehci-tegra.c | 2 +-
drivers/usb/host/ehci.h | 4 ++--
drivers/usb/host/fotg210.h | 2 +-
drivers/usb/host/ohci.h | 4 ++--
drivers/usb/host/xhci-mtk.h | 2 +-
drivers/usb/host/xhci.h | 4 ++--
drivers/usb/serial/io_usbvend.h | 4 ++--
drivers/usb/serial/ti_usb_3410_5052.c | 4 ++--
include/linux/usb.h | 4 ++--
include/linux/usb/audio-v2.h | 2 +-
include/linux/usb/audio-v3.h | 2 +-
include/linux/usb/gadget.h | 2 +-
include/linux/usb/hcd.h | 2 +-
include/linux/usbdevice_fs.h | 2 +-
16 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h
index d3bdc4cc47aa..8725755bd53d 100644
--- a/drivers/usb/atm/usbatm.h
+++ b/drivers/usb/atm/usbatm.h
@@ -164,7 +164,7 @@ struct usbatm_data {
unsigned char *cell_buf; /* holds partial rx cell */
unsigned int buf_usage;
- struct urb *urbs[0];
+ struct urb *urbs[];
};
static inline void *to_usbatm_driver_data(struct usb_interface *intf)
diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h
index 8ca6d12a6f57..1224fa9df604 100644
--- a/drivers/usb/dwc2/hcd.h
+++ b/drivers/usb/dwc2/hcd.h
@@ -199,7 +199,7 @@ struct dwc2_hcd_urb {
u32 flags;
u16 interval;
struct dwc2_hcd_pipe_info pipe_info;
- struct dwc2_hcd_iso_packet_desc iso_descs[0];
+ struct dwc2_hcd_iso_packet_desc iso_descs[];
};
/* Phases for control transfers */
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index d6433f206c17..10d51daa6a1b 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -282,7 +282,7 @@ static int tegra_ehci_hub_control(
struct dma_aligned_buffer {
void *kmalloc_ptr;
void *old_xfer_buffer;
- u8 data[0];
+ u8 data[];
};
static void free_dma_aligned_buffer(struct urb *urb)
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index ac5e967907d1..229b3de319e6 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -255,7 +255,7 @@ struct ehci_hcd { /* one per controller */
struct list_head tt_list;
/* platform-specific data -- must come last */
- unsigned long priv[0] __aligned(sizeof(s64));
+ unsigned long priv[] __aligned(sizeof(s64));
};
/* convert between an HCD pointer and the corresponding EHCI_HCD */
@@ -460,7 +460,7 @@ struct ehci_iso_sched {
struct list_head td_list;
unsigned span;
unsigned first_packet;
- struct ehci_iso_packet packet[0];
+ struct ehci_iso_packet packet[];
};
/*
diff --git a/drivers/usb/host/fotg210.h b/drivers/usb/host/fotg210.h
index 1b4db95e5c43..6cee40ec65b4 100644
--- a/drivers/usb/host/fotg210.h
+++ b/drivers/usb/host/fotg210.h
@@ -490,7 +490,7 @@ struct fotg210_iso_packet {
struct fotg210_iso_sched {
struct list_head td_list;
unsigned span;
- struct fotg210_iso_packet packet[0];
+ struct fotg210_iso_packet packet[];
};
/*
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
index b015b00774b2..27c26ca10bfd 100644
--- a/drivers/usb/host/ohci.h
+++ b/drivers/usb/host/ohci.h
@@ -337,7 +337,7 @@ typedef struct urb_priv {
u16 length; // # tds in this request
u16 td_cnt; // tds already serviced
struct list_head pending;
- struct td *td [0]; // all TDs in this request
+ struct td *td[]; // all TDs in this request
} urb_priv_t;
@@ -435,7 +435,7 @@ struct ohci_hcd {
struct dentry *debug_dir;
/* platform-specific data -- must come last */
- unsigned long priv[0] __aligned(sizeof(s64));
+ unsigned long priv[] __aligned(sizeof(s64));
};
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 5ac458b7d2e0..acd56517215a 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -95,7 +95,7 @@ struct mu3h_sch_ep_info {
u32 pkts;
u32 cs_count;
u32 burst_mode;
- u32 bw_budget_table[0];
+ u32 bw_budget_table[];
};
#define MU3C_U3_PORT_MAX 4
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 3ecee10fdcdc..685180e1b98a 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1642,7 +1642,7 @@ struct xhci_scratchpad {
struct urb_priv {
int num_tds;
int num_tds_done;
- struct xhci_td td[0];
+ struct xhci_td td[];
};
/*
@@ -1901,7 +1901,7 @@ struct xhci_hcd {
void *dbc;
/* platform-specific data -- must come last */
- unsigned long priv[0] __aligned(sizeof(s64));
+ unsigned long priv[] __aligned(sizeof(s64));
};
/* Platform specific overrides to generic XHCI hc_driver ops */
diff --git a/drivers/usb/serial/io_usbvend.h b/drivers/usb/serial/io_usbvend.h
index c38e87ac5ea9..0d1a5bb4636e 100644
--- a/drivers/usb/serial/io_usbvend.h
+++ b/drivers/usb/serial/io_usbvend.h
@@ -593,7 +593,7 @@ struct ti_i2c_desc {
__u8 Type; // Type of descriptor
__le16 Size; // Size of data only not including header
__u8 CheckSum; // Checksum (8 bit sum of data only)
- __u8 Data[0]; // Data starts here
+ __u8 Data[]; // Data starts here
} __attribute__((packed));
// for 5152 devices only (type 2 record)
@@ -601,7 +601,7 @@ struct ti_i2c_desc {
struct ti_i2c_firmware_rec {
__u8 Ver_Major; // Firmware Major version number
__u8 Ver_Minor; // Firmware Minor version number
- __u8 Data[0]; // Download starts here
+ __u8 Data[]; // Download starts here
} __attribute__((packed));
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index ef23acc9b9ce..73075b9351c5 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -219,7 +219,7 @@ struct ti_write_data_bytes {
u8 bDataCounter;
__be16 wBaseAddrHi;
__be16 wBaseAddrLo;
- u8 bData[0];
+ u8 bData[];
} __packed;
struct ti_read_data_request {
@@ -234,7 +234,7 @@ struct ti_read_data_bytes {
__u8 bCmdCode;
__u8 bModuleId;
__u8 bErrorCode;
- __u8 bData[0];
+ __u8 bData[];
} __packed;
/* Interrupt struct */
diff --git a/include/linux/usb.h b/include/linux/usb.h
index ca1a5f1e1c5e..9f3c721c70dc 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -325,7 +325,7 @@ struct usb_interface_cache {
/* variable-length array of alternate settings for this interface,
* stored in no particular order */
- struct usb_host_interface altsetting[0];
+ struct usb_host_interface altsetting[];
};
#define ref_to_usb_interface_cache(r) \
container_of(r, struct usb_interface_cache, ref)
@@ -1589,7 +1589,7 @@ struct urb {
int error_count; /* (return) number of ISO errors */
void *context; /* (in) context for completion */
usb_complete_t complete; /* (in) completion routine */
- struct usb_iso_packet_descriptor iso_frame_desc[0];
+ struct usb_iso_packet_descriptor iso_frame_desc[];
/* (in) ISO ONLY */
};
diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h
index cb9900b34b67..ead8c9a47c6a 100644
--- a/include/linux/usb/audio-v2.h
+++ b/include/linux/usb/audio-v2.h
@@ -153,7 +153,7 @@ struct uac2_feature_unit_descriptor {
__u8 bSourceID;
/* bmaControls is actually u32,
* but u8 is needed for the hybrid parser */
- __u8 bmaControls[0]; /* variable length */
+ __u8 bmaControls[]; /* variable length */
} __attribute__((packed));
/* 4.7.2.10 Effect Unit Descriptor */
diff --git a/include/linux/usb/audio-v3.h b/include/linux/usb/audio-v3.h
index 6b708434b7f9..c69a6f2e6837 100644
--- a/include/linux/usb/audio-v3.h
+++ b/include/linux/usb/audio-v3.h
@@ -109,7 +109,7 @@ struct uac3_feature_unit_descriptor {
__u8 bSourceID;
/* bmaControls is actually u32,
* but u8 is needed for the hybrid parser */
- __u8 bmaControls[0]; /* variable length */
+ __u8 bmaControls[]; /* variable length */
/* wFeatureDescrStr omitted */
} __attribute__((packed));
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 124462d65eac..9411c08a5c7e 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -767,7 +767,7 @@ struct usb_gadget_strings {
struct usb_gadget_string_container {
struct list_head list;
- u8 *stash[0];
+ u8 *stash[];
};
/* put descriptor for string with that id into buf (buflen >= 256) */
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 712b2a603645..e12105ed3834 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -228,7 +228,7 @@ struct usb_hcd {
/* The HC driver's private data is stored at the end of
* this structure.
*/
- unsigned long hcd_priv[0]
+ unsigned long hcd_priv[]
__attribute__ ((aligned(sizeof(s64))));
};
diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h
index 79aab0065ec8..14ea197ce37f 100644
--- a/include/linux/usbdevice_fs.h
+++ b/include/linux/usbdevice_fs.h
@@ -69,7 +69,7 @@ struct usbdevfs_urb32 {
compat_int_t error_count;
compat_uint_t signr;
compat_caddr_t usercontext; /* unused */
- struct usbdevfs_iso_packet_desc iso_frame_desc[0];
+ struct usbdevfs_iso_packet_desc iso_frame_desc[];
};
struct usbdevfs_ioctl32 {
--
2.25.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related
* Re: [PATCH net-next] net: mscc: ocelot: Workaround to allow traffic to CPU in standalone mode
From: Allan W. Nielsen @ 2020-02-20 13:23 UTC (permalink / raw)
To: Vladimir Oltean
Cc: Andrew Lunn, David S. Miller, Horatiu Vultur, Alexandre Belloni,
Florian Fainelli, Vivien Didelot, Joergen Andreasen,
Claudiu Manoil, netdev, Microchip Linux Driver Support
In-Reply-To: <CA+h21hp5NQNJJ5agMPAZ+edaZ+ouSjTJ8DypYR5Htx3ZT5iSYA@mail.gmail.com>
Hi,
On 19.02.2020 16:05, Vladimir Oltean wrote:
>On Wed, 19 Feb 2020 at 12:17, Allan W. Nielsen
><allan.nielsen@microchip.com> wrote:
>>
>> With Ocelot we do not see this spamming - and I still do not understand
>> why this is seen with Felix.
>>
>
>I should have watched my words.
>When doing what all the other DSA switches do, which is enabling a
>bulk forwarding path between the front-panel ports and the CPU, the
>Ocelot switch core is more susceptible to doing more software
>processing work than other devices in its class, for the same end
>effect of dropping packets that the CPU is not interested in (say an
>unknown unicast MAC that is not present in the switch FDB nor in the
>DSA master's RX filter). In such a scenario, any other DSA system
>would have the host port drop these packets in hardware, by virtue of
>the unknown unicast MAC not being being present RX filter. With
>Ocelot, this mechanism that prevents software work being done for
>dropping is subverted. So to avoid this design limitation, the Ocelot
>core does not enable a bulk forwarding path between the front-panel
>ports and the CPU.
>
>Hope this is clearer.
Horatiu and I have looked further into this, done a few experiments, and
discussed with the HW engineers who have a more detailed version of how
the chips are working and how Ocelot and Felix differs.
Here are our findings:
- The most significant bit in the PGID table is "special" as it is a
CPU-copy bit.
- This bit is not being used in the source filtering! This means that
your original patch can be applied without breaking Ocelot (the
uninitialized cpu field must be fixed though).
- Still I do not think we should do this as it is not the root-casuse
- In Felix we have 2 ways to get frames to the CPU, in Ocelot we have 1
(Ocelot also has two if it uses an NPI port, but it does not do that
in the current driver).
- In Felix you can get frames to the CPU by either using the CPU port
(port 6), or by using the NPI port (which can be any in the range of
0-5).
- But you should only use the CPU port, and not the NPI port
directly. Using the NPI port directly will cause the two targets
to behave differently, and this is not what we do when testing all
the use-cases on the switch.
- In Ocelot you can only get frames to the CPU by using the CPU port
(port 11).
Due to this, I very much think you need to fix this, such that Felix
always port 6 to reach the CPU (with the exception of writing
QSYS_EXT_CPU_CFG where you "connect" the CPU queue/port to the NPI
port).
If you do this change, then the Ocelot and Felix should start to work in
the same way.
Then, if you want the CPU to be part of the unicast flooding (this is
where this discussion started), then you should add the CPU port to the
PGID entry pointed at in ANA:ANA:FLOODING:FLD_UNICAST. This should be
done for Felix and not for Ocelot.
If you want the analyser (where the MAC table sits), to "learn" the CPU
MAC (which is needed if you do not want to have the CPU mac as a static
entry in the MAC-table), then you need to set the 'src-port' to 6 (if it
is Ocelot then it will be 11) in the IFH:
anielsen@lx-anielsen ~ $ ef hex ifh-oc1 help
ifh-oc1 Injection Frame Header for Ocelot1
Specify the ifh-oc1 header by using one or more of the following fields:
- Name ------------ offset:width --- Description --------------------------
bypass + 0: 1 Skip analyzer processing
b1-rew-mac + 1: 1 Replace SMAC address
b1-rew-op + 2: 9 Rewriter operation command
b0-masq + 1: 1 Enable masquerading
b0-masq-port + 2: 4 Masquerading port
rew-val + 11: 32 Receive time stamp
res1 + 43: 17 Reserved
dest + 60: 12 Destination set for the frame. Dest[11] is the CPU
res2 + 72: 9 Reserved
src-port + 81: 4 The port number where the frame was injected (0-12) <------------------- THIS FIELD
res3 + 85: 2 Reserved
trfm-timer + 87: 4 Timer for periodic transmissions (1..8). If zero then normal injection
res4 + 91: 6 Reserved
dp + 97: 1 Drop precedence level after policing
pop-cnt + 98: 2 Number of VLAN tags that must be popped
cpuq +100: 8 CPU extraction queue mask
qos-class +108: 3 Classified QoS class
tag-type +111: 1 Tag information's associated Tag Protocol Identifier (TPID)
pcp +112: 3 Classified PCP
dei +115: 1 Classified DEI
vid +116: 12 Classified VID
/Allan
^ permalink raw reply
* Re: [dpdk-dev] [PATCH v2] net/mlx5: fix match on Ethertype and CVLAN tag
From: Raslan Darawsheh @ 2020-02-20 13:23 UTC (permalink / raw)
To: Dekel Peled, Matan Azrad, Slava Ovsiienko; +Cc: dev@dpdk.org, stable@dpdk.org
In-Reply-To: <b58f1aaed9b164a10f7a5efa6814c1975f9ecab6.1582198154.git.dekelp@mellanox.com>
Hi,
> -----Original Message-----
> From: Dekel Peled <dekelp@mellanox.com>
> Sent: Thursday, February 20, 2020 1:33 PM
> To: Matan Azrad <matan@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>; Raslan Darawsheh <rasland@mellanox.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: [PATCH v2] net/mlx5: fix match on Ethertype and CVLAN tag
>
> HW supports match on one Ethertype, the Ethertype following the last
> VLAN tag of the packet (see PRM).
> Previous patch added specific handling for packets with VLAN tag,
> after setting match on Ethertype.
>
> This patch moves the handling of packets with VLAN tag, to be done
> before and instead of setting match on Ethertype.
>
> Previous patch also added, as part of specific handling for packets
> with VLAN tag, the setting of cvlan_tag mask bit in translation of
> L3 items.
> In case of L3 tunnel there is no inner L2 header, so setting this
> mask bit is wrong and causes match failures.
>
> This patch adds check to make sure L2 header exists before setting
> cvlan_tag mask bit for L3 items.
>
> Fixes: 00f75a40576b ("net/mlx5: fix VLAN match for DV mode")
> Cc: stable@dpdk.org
>
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Tested-by: Raslan Darawsheh <rasland@mellanox.com>
> ---
> drivers/net/mlx5/mlx5_flow_dv.c | 42
> ++++++++++++++++++++++++++++++++---------
> 1 file changed, 33 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
> b/drivers/net/mlx5/mlx5_flow_dv.c
> index 467d1ce..6f15a91 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -5213,19 +5213,27 @@ struct field_modify_info modify_tcp[] = {
> /* The value must be in the range of the mask. */
> for (i = 0; i < sizeof(eth_m->dst); ++i)
> l24_v[i] = eth_m->src.addr_bytes[i] & eth_v-
> >src.addr_bytes[i];
> - MLX5_SET(fte_match_set_lyr_2_4, headers_m, ethertype,
> - rte_be_to_cpu_16(eth_m->type));
> - l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
> ethertype);
> - *(uint16_t *)(l24_v) = eth_m->type & eth_v->type;
> if (eth_v->type) {
> /* When ethertype is present set mask for tagged VLAN. */
> MLX5_SET(fte_match_set_lyr_2_4, headers_m, cvlan_tag,
> 1);
> /* Set value for tagged VLAN if ethertype is 802.1Q. */
> if (eth_v->type == RTE_BE16(RTE_ETHER_TYPE_VLAN) ||
> - eth_v->type == RTE_BE16(RTE_ETHER_TYPE_QINQ))
> + eth_v->type == RTE_BE16(RTE_ETHER_TYPE_QINQ)) {
> MLX5_SET(fte_match_set_lyr_2_4, headers_v,
> cvlan_tag,
> 1);
> + /* Return here to avoid setting match on ethertype.
> */
> + return;
> + }
> }
> + /*
> + * HW supports match on one Ethertype, the Ethertype following the
> last
> + * VLAN tag of the packet (see PRM).
> + * Set match on ethertype only if ETH header is not followed by
> VLAN.
> + */
> + MLX5_SET(fte_match_set_lyr_2_4, headers_m, ethertype,
> + rte_be_to_cpu_16(eth_m->type));
> + l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
> ethertype);
> + *(uint16_t *)(l24_v) = eth_m->type & eth_v->type;
> }
>
> /**
> @@ -5299,6 +5307,8 @@ struct field_modify_info modify_tcp[] = {
> * Flow matcher value.
> * @param[in] item
> * Flow pattern to translate.
> + * @param[in] item_flags
> + * Bit-fields that holds the items detected until now.
> * @param[in] inner
> * Item is inner pattern.
> * @param[in] group
> @@ -5307,6 +5317,7 @@ struct field_modify_info modify_tcp[] = {
> static void
> flow_dv_translate_item_ipv4(void *matcher, void *key,
> const struct rte_flow_item *item,
> + const uint64_t item_flags,
> int inner, uint32_t group)
> {
> const struct rte_flow_item_ipv4 *ipv4_m = item->mask;
> @@ -5366,7 +5377,12 @@ struct field_modify_info modify_tcp[] = {
> ipv4_m->hdr.next_proto_id);
> MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol,
> ipv4_v->hdr.next_proto_id & ipv4_m->hdr.next_proto_id);
> - MLX5_SET(fte_match_set_lyr_2_4, headers_m, cvlan_tag, 1);
> + /*
> + * On outer header (which must contains L2), or inner header with L2,
> + * set cvlan_tag mask bit to mark this packet as untagged.
> + */
> + if (!inner || item_flags & MLX5_FLOW_LAYER_INNER_L2)
> + MLX5_SET(fte_match_set_lyr_2_4, headers_m, cvlan_tag,
> 1);
> }
>
> /**
> @@ -5378,6 +5394,8 @@ struct field_modify_info modify_tcp[] = {
> * Flow matcher value.
> * @param[in] item
> * Flow pattern to translate.
> + * @param[in] item_flags
> + * Bit-fields that holds the items detected until now.
> * @param[in] inner
> * Item is inner pattern.
> * @param[in] group
> @@ -5386,6 +5404,7 @@ struct field_modify_info modify_tcp[] = {
> static void
> flow_dv_translate_item_ipv6(void *matcher, void *key,
> const struct rte_flow_item *item,
> + const uint64_t item_flags,
> int inner, uint32_t group)
> {
> const struct rte_flow_item_ipv6 *ipv6_m = item->mask;
> @@ -5471,7 +5490,12 @@ struct field_modify_info modify_tcp[] = {
> ipv6_m->hdr.proto);
> MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol,
> ipv6_v->hdr.proto & ipv6_m->hdr.proto);
> - MLX5_SET(fte_match_set_lyr_2_4, headers_m, cvlan_tag, 1);
> + /*
> + * On outer header (which must contains L2), or inner header with L2,
> + * set cvlan_tag mask bit to mark this packet as untagged.
> + */
> + if (!inner || item_flags & MLX5_FLOW_LAYER_INNER_L2)
> + MLX5_SET(fte_match_set_lyr_2_4, headers_m, cvlan_tag,
> 1);
> }
>
> /**
> @@ -7574,7 +7598,7 @@ struct field_modify_info modify_tcp[] = {
> mlx5_flow_tunnel_ip_check(items, next_protocol,
> &item_flags, &tunnel);
> flow_dv_translate_item_ipv4(match_mask,
> match_value,
> - items, tunnel,
> + items, item_flags, tunnel,
> dev_flow->group);
> matcher.priority = MLX5_PRIORITY_MAP_L3;
> last_item = tunnel ?
> MLX5_FLOW_LAYER_INNER_L3_IPV4 :
> @@ -7597,7 +7621,7 @@ struct field_modify_info modify_tcp[] = {
> mlx5_flow_tunnel_ip_check(items, next_protocol,
> &item_flags, &tunnel);
> flow_dv_translate_item_ipv6(match_mask,
> match_value,
> - items, tunnel,
> + items, item_flags, tunnel,
> dev_flow->group);
> matcher.priority = MLX5_PRIORITY_MAP_L3;
> last_item = tunnel ?
> MLX5_FLOW_LAYER_INNER_L3_IPV6 :
> --
> 1.8.3.1
Patch applied to next-net-mlx,
Kindest regards
Raslan Darawsheh
^ permalink raw reply
* Re: [PATCH v3 03/20] exec: Let qemu_ram_*() functions take a const pointer argument
From: Paolo Bonzini @ 2020-02-20 13:21 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Peter Maydell, qemu-devel
Cc: Fam Zheng, Dmitry Fleytman, kvm, Michael S. Tsirkin, Jason Wang,
Gerd Hoffmann, Edgar E. Iglesias, Stefano Stabellini,
Matthew Rosato, qemu-block, David Hildenbrand, Halil Pasic,
Christian Borntraeger, Hervé Poussineau, Anthony Perard,
xen-devel, Aleksandar Rikalo, Richard Henderson, Laurent Vivier,
Thomas Huth, Eduardo Habkost, Stefan Weil, Alistair Francis,
Richard Henderson, Paul Durrant, Eric Auger, qemu-s390x, qemu-arm,
Cédric Le Goater, John Snow, David Gibson, Igor Mitsyanko,
Cornelia Huck, Michael Walle, qemu-ppc
In-Reply-To: <20200220130548.29974-4-philmd@redhat.com>
On 20/02/20 14:05, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> include/exec/cpu-common.h | 6 +++---
> include/sysemu/xen-mapcache.h | 4 ++--
> exec.c | 8 ++++----
> hw/i386/xen/xen-mapcache.c | 2 +-
> 4 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
> index 81753bbb34..05ac1a5d69 100644
> --- a/include/exec/cpu-common.h
> +++ b/include/exec/cpu-common.h
> @@ -48,11 +48,11 @@ typedef uint32_t CPUReadMemoryFunc(void *opaque, hwaddr addr);
>
> void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
> /* This should not be used by devices. */
> -ram_addr_t qemu_ram_addr_from_host(void *ptr);
> +ram_addr_t qemu_ram_addr_from_host(const void *ptr);
This is a bit ugly, because the pointer _can_ be modified via
qemu_map_ram_ptr. Is this needed for the rest of the series to apply?
Paolo
> RAMBlock *qemu_ram_block_by_name(const char *name);
> -RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
> +RAMBlock *qemu_ram_block_from_host(const void *ptr, bool round_offset,
> ram_addr_t *offset);
> -ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host);
> +ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, const void *host);
> void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
> void qemu_ram_unset_idstr(RAMBlock *block);
> const char *qemu_ram_get_idstr(RAMBlock *rb);
> diff --git a/include/sysemu/xen-mapcache.h b/include/sysemu/xen-mapcache.h
> index c8e7c2f6cf..81e9aa2fa6 100644
> --- a/include/sysemu/xen-mapcache.h
> +++ b/include/sysemu/xen-mapcache.h
> @@ -19,7 +19,7 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f,
> void *opaque);
> uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size,
> uint8_t lock, bool dma);
> -ram_addr_t xen_ram_addr_from_mapcache(void *ptr);
> +ram_addr_t xen_ram_addr_from_mapcache(const void *ptr);
> void xen_invalidate_map_cache_entry(uint8_t *buffer);
> void xen_invalidate_map_cache(void);
> uint8_t *xen_replace_cache_entry(hwaddr old_phys_addr,
> @@ -40,7 +40,7 @@ static inline uint8_t *xen_map_cache(hwaddr phys_addr,
> abort();
> }
>
> -static inline ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
> +static inline ram_addr_t xen_ram_addr_from_mapcache(const void *ptr)
> {
> abort();
> }
> diff --git a/exec.c b/exec.c
> index 8e9cc3b47c..02b4e6ea41 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -2614,7 +2614,7 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr,
> }
>
> /* Return the offset of a hostpointer within a ramblock */
> -ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host)
> +ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, const void *host)
> {
> ram_addr_t res = (uint8_t *)host - (uint8_t *)rb->host;
> assert((uintptr_t)host >= (uintptr_t)rb->host);
> @@ -2640,11 +2640,11 @@ ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host)
> * pointer, such as a reference to the region that includes the incoming
> * ram_addr_t.
> */
> -RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
> +RAMBlock *qemu_ram_block_from_host(const void *ptr, bool round_offset,
> ram_addr_t *offset)
> {
> RAMBlock *block;
> - uint8_t *host = ptr;
> + const uint8_t *host = ptr;
>
> if (xen_enabled()) {
> ram_addr_t ram_addr;
> @@ -2705,7 +2705,7 @@ RAMBlock *qemu_ram_block_by_name(const char *name)
>
> /* Some of the softmmu routines need to translate from a host pointer
> (typically a TLB entry) back to a ram offset. */
> -ram_addr_t qemu_ram_addr_from_host(void *ptr)
> +ram_addr_t qemu_ram_addr_from_host(const void *ptr)
> {
> RAMBlock *block;
> ram_addr_t offset;
> diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c
> index 5b120ed44b..432ad3354d 100644
> --- a/hw/i386/xen/xen-mapcache.c
> +++ b/hw/i386/xen/xen-mapcache.c
> @@ -363,7 +363,7 @@ uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size,
> return p;
> }
>
> -ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
> +ram_addr_t xen_ram_addr_from_mapcache(const void *ptr)
> {
> MapCacheEntry *entry = NULL;
> MapCacheRev *reventry;
>
^ permalink raw reply
* [PATCH] s390/sclp: improve special wait psw logic
From: Christian Borntraeger @ 2020-02-20 13:16 UTC (permalink / raw)
To: Cornelia Huck
Cc: Janosch Frank, David Hildenbrand, qemu-devel, qemu-stable,
Christian Borntraeger, qemu-s390x, Richard Henderson
There is a special quiesce PSW that we check for "shutdown". Otherwise disabled
wait is detected as "crashed". Architecturally we must only check PSW bits
116-127. Fix this.
Cc: qemu-stable@nongnu.org
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
target/s390x/helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/s390x/helper.c b/target/s390x/helper.c
index a3a4916..6808dfd 100644
--- a/target/s390x/helper.c
+++ b/target/s390x/helper.c
@@ -89,7 +89,7 @@ hwaddr s390_cpu_get_phys_addr_debug(CPUState *cs, vaddr vaddr)
static inline bool is_special_wait_psw(uint64_t psw_addr)
{
/* signal quiesce */
- return psw_addr == 0xfffUL;
+ return (psw_addr & 0xfffUL) == 0xfffUL;
}
void s390_handle_wait(S390CPU *cpu)
--
1.8.3.1
^ permalink raw reply related
* [PATCH v3 17/20] Avoid address_space_rw() with a constant is_write argument
From: Philippe Mathieu-Daudé @ 2020-02-20 13:05 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
Cc: Fam Zheng, Dmitry Fleytman, kvm, Michael S. Tsirkin, Jason Wang,
Alistair Francis, Gerd Hoffmann, Edgar E. Iglesias,
Edgar E . Iglesias, Stefano Stabellini, Matthew Rosato,
qemu-block, David Hildenbrand, Halil Pasic, Christian Borntraeger,
Hervé Poussineau, Anthony Perard, xen-devel,
Aleksandar Rikalo, Richard Henderson, Philippe Mathieu-Daudé,
Laurent Vivier, Thomas Huth, Eduardo Habkost, Stefan Weil,
Alistair Francis, Richard Henderson, Paul Durrant, Eric Auger,
qemu-s390x, qemu-arm, Cédric Le Goater, John Snow,
David Gibson, Igor Mitsyanko, Cornelia Huck, Michael Walle,
qemu-ppc, Paolo Bonzini
In-Reply-To: <20200220130548.29974-1-philmd@redhat.com>
From: Peter Maydell <peter.maydell@linaro.org>
The address_space_rw() function allows either reads or writes
depending on the is_write argument passed to it; this is useful
when the direction of the access is determined programmatically
(as for instance when handling the KVM_EXIT_MMIO exit reason).
Under the hood it just calls either address_space_write() or
address_space_read_full().
We also use it a lot with a constant is_write argument, though,
which has two issues:
* when reading "address_space_rw(..., 1)" this is less
immediately clear to the reader as being a write than
"address_space_write(...)"
* calling address_space_rw() bypasses the optimization
in address_space_read() that fast-paths reads of a
fixed length
This commit was produced with the included Coccinelle script
scripts/coccinelle/exec_rw_const.cocci.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20200218112457.22712-1-peter.maydell@linaro.org>
[PMD: Update macvm_set_cr0() reported by Laurent Vivier]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
scripts/coccinelle/exec_rw_const.cocci | 13 +++++
target/i386/hvf/vmx.h | 7 ++-
accel/kvm/kvm-all.c | 6 +--
dma-helpers.c | 4 +-
exec.c | 4 +-
hw/dma/xlnx-zdma.c | 11 ++--
hw/net/dp8393x.c | 70 ++++++++++++++------------
hw/net/i82596.c | 22 ++++----
hw/net/lasi_i82596.c | 5 +-
hw/ppc/pnv_lpc.c | 8 +--
hw/s390x/css.c | 12 ++---
qtest.c | 52 +++++++++----------
target/i386/hvf/x86_mmu.c | 12 ++---
13 files changed, 119 insertions(+), 107 deletions(-)
diff --git a/scripts/coccinelle/exec_rw_const.cocci b/scripts/coccinelle/exec_rw_const.cocci
index 98cb06f09f..ee98ce988e 100644
--- a/scripts/coccinelle/exec_rw_const.cocci
+++ b/scripts/coccinelle/exec_rw_const.cocci
@@ -27,6 +27,19 @@ expression E1, E2, E3, E4;
+ address_space_write(E1, E2, E3, V, E4)
)
+// Avoid uses of address_space_rw() with a constant is_write argument.
+@@
+expression E1, E2, E3, E4, E5;
+symbol true, false;
+@@
+(
+- address_space_rw(E1, E2, E3, E4, E5, false)
++ address_space_read(E1, E2, E3, E4, E5)
+|
+- address_space_rw(E1, E2, E3, E4, E5, true)
++ address_space_write(E1, E2, E3, E4, E5)
+)
+
// Remove useless cast
@@
expression E1, E2, E3, E4, E5, E6;
diff --git a/target/i386/hvf/vmx.h b/target/i386/hvf/vmx.h
index 19af029133..03d2c79b9c 100644
--- a/target/i386/hvf/vmx.h
+++ b/target/i386/hvf/vmx.h
@@ -125,10 +125,9 @@ static inline void macvm_set_cr0(hv_vcpuid_t vcpu, uint64_t cr0)
if ((cr0 & CR0_PG) && (rvmcs(vcpu, VMCS_GUEST_CR4) & CR4_PAE) &&
!(efer & MSR_EFER_LME)) {
- address_space_rw(&address_space_memory,
- rvmcs(vcpu, VMCS_GUEST_CR3) & ~0x1f,
- MEMTXATTRS_UNSPECIFIED,
- pdpte, 32, false);
+ address_space_read(&address_space_memory,
+ rvmcs(vcpu, VMCS_GUEST_CR3) & ~0x1f,
+ MEMTXATTRS_UNSPECIFIED, pdpte, 32);
/* Only set PDPTE when appropriate. */
for (i = 0; i < 4; i++) {
wvmcs(vcpu, VMCS_GUEST_PDPTE0 + i * 2, pdpte[i]);
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index c111312dfd..0cfe6fd8de 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2178,9 +2178,9 @@ void kvm_flush_coalesced_mmio_buffer(void)
ent = &ring->coalesced_mmio[ring->first];
if (ent->pio == 1) {
- address_space_rw(&address_space_io, ent->phys_addr,
- MEMTXATTRS_UNSPECIFIED, ent->data,
- ent->len, true);
+ address_space_write(&address_space_io, ent->phys_addr,
+ MEMTXATTRS_UNSPECIFIED, ent->data,
+ ent->len);
} else {
cpu_physical_memory_write(ent->phys_addr, ent->data, ent->len);
}
diff --git a/dma-helpers.c b/dma-helpers.c
index d3871dc61e..e8a26e81e1 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -28,8 +28,8 @@ int dma_memory_set(AddressSpace *as, dma_addr_t addr, uint8_t c, dma_addr_t len)
memset(fillbuf, c, FILLBUF_SIZE);
while (len > 0) {
l = len < FILLBUF_SIZE ? len : FILLBUF_SIZE;
- error |= address_space_rw(as, addr, MEMTXATTRS_UNSPECIFIED,
- fillbuf, l, true);
+ error |= address_space_write(as, addr, MEMTXATTRS_UNSPECIFIED,
+ fillbuf, l);
len -= l;
addr += l;
}
diff --git a/exec.c b/exec.c
index 73c3bcfa40..b79919a4f7 100644
--- a/exec.c
+++ b/exec.c
@@ -3815,8 +3815,8 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr,
address_space_write_rom(cpu->cpu_ases[asidx].as, phys_addr,
attrs, buf, l);
} else {
- address_space_rw(cpu->cpu_ases[asidx].as, phys_addr, attrs, buf,
- l, false);
+ address_space_read(cpu->cpu_ases[asidx].as, phys_addr, attrs, buf,
+ l);
}
len -= l;
buf += l;
diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c
index 683abbe53f..1c1b142293 100644
--- a/hw/dma/xlnx-zdma.c
+++ b/hw/dma/xlnx-zdma.c
@@ -311,8 +311,7 @@ static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, void *buf)
return false;
}
- address_space_rw(s->dma_as, addr, s->attr,
- buf, sizeof(XlnxZDMADescr), false);
+ address_space_read(s->dma_as, addr, s->attr, buf, sizeof(XlnxZDMADescr));
return true;
}
@@ -364,7 +363,7 @@ static uint64_t zdma_update_descr_addr(XlnxZDMA *s, bool type,
} else {
addr = zdma_get_regaddr64(s, basereg);
addr += sizeof(s->dsc_dst);
- address_space_rw(s->dma_as, addr, s->attr, &next, 8, false);
+ address_space_read(s->dma_as, addr, s->attr, &next, 8);
zdma_put_regaddr64(s, basereg, next);
}
return next;
@@ -416,8 +415,7 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)
}
}
- address_space_rw(s->dma_as, s->dsc_dst.addr, s->attr, buf, dlen,
- true);
+ address_space_write(s->dma_as, s->dsc_dst.addr, s->attr, buf, dlen);
if (burst_type == AXI_BURST_INCR) {
s->dsc_dst.addr += dlen;
}
@@ -493,8 +491,7 @@ static void zdma_process_descr(XlnxZDMA *s)
len = s->cfg.bus_width / 8;
}
} else {
- address_space_rw(s->dma_as, src_addr, s->attr, s->buf, len,
- false);
+ address_space_read(s->dma_as, src_addr, s->attr, s->buf, len);
if (burst_type == AXI_BURST_INCR) {
src_addr += len;
}
diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
index b4363e3186..70451934ae 100644
--- a/hw/net/dp8393x.c
+++ b/hw/net/dp8393x.c
@@ -275,8 +275,8 @@ static void dp8393x_do_load_cam(dp8393xState *s)
while (s->regs[SONIC_CDC] & 0x1f) {
/* Fill current entry */
- address_space_rw(&s->as, dp8393x_cdp(s),
- MEMTXATTRS_UNSPECIFIED, s->data, size, false);
+ address_space_read(&s->as, dp8393x_cdp(s),
+ MEMTXATTRS_UNSPECIFIED, s->data, size);
s->cam[index][0] = dp8393x_get(s, width, 1) & 0xff;
s->cam[index][1] = dp8393x_get(s, width, 1) >> 8;
s->cam[index][2] = dp8393x_get(s, width, 2) & 0xff;
@@ -293,8 +293,8 @@ static void dp8393x_do_load_cam(dp8393xState *s)
}
/* Read CAM enable */
- address_space_rw(&s->as, dp8393x_cdp(s),
- MEMTXATTRS_UNSPECIFIED, s->data, size, false);
+ address_space_read(&s->as, dp8393x_cdp(s),
+ MEMTXATTRS_UNSPECIFIED, s->data, size);
s->regs[SONIC_CE] = dp8393x_get(s, width, 0);
DPRINTF("load cam done. cam enable mask 0x%04x\n", s->regs[SONIC_CE]);
@@ -311,8 +311,8 @@ static void dp8393x_do_read_rra(dp8393xState *s)
/* Read memory */
width = (s->regs[SONIC_DCR] & SONIC_DCR_DW) ? 2 : 1;
size = sizeof(uint16_t) * 4 * width;
- address_space_rw(&s->as, dp8393x_rrp(s),
- MEMTXATTRS_UNSPECIFIED, s->data, size, false);
+ address_space_read(&s->as, dp8393x_rrp(s),
+ MEMTXATTRS_UNSPECIFIED, s->data, size);
/* Update SONIC registers */
s->regs[SONIC_CRBA0] = dp8393x_get(s, width, 0);
@@ -426,8 +426,8 @@ static void dp8393x_do_transmit_packets(dp8393xState *s)
size = sizeof(uint16_t) * 6 * width;
s->regs[SONIC_TTDA] = s->regs[SONIC_CTDA];
DPRINTF("Transmit packet at %08x\n", dp8393x_ttda(s));
- address_space_rw(&s->as, dp8393x_ttda(s) + sizeof(uint16_t) * width,
- MEMTXATTRS_UNSPECIFIED, s->data, size, false);
+ address_space_read(&s->as, dp8393x_ttda(s) + sizeof(uint16_t) * width,
+ MEMTXATTRS_UNSPECIFIED, s->data, size);
tx_len = 0;
/* Update registers */
@@ -451,18 +451,19 @@ static void dp8393x_do_transmit_packets(dp8393xState *s)
if (tx_len + len > sizeof(s->tx_buffer)) {
len = sizeof(s->tx_buffer) - tx_len;
}
- address_space_rw(&s->as, dp8393x_tsa(s),
- MEMTXATTRS_UNSPECIFIED,
- &s->tx_buffer[tx_len], len, false);
+ address_space_read(&s->as, dp8393x_tsa(s), MEMTXATTRS_UNSPECIFIED,
+ &s->tx_buffer[tx_len], len);
tx_len += len;
i++;
if (i != s->regs[SONIC_TFC]) {
/* Read next fragment details */
size = sizeof(uint16_t) * 3 * width;
- address_space_rw(&s->as,
- dp8393x_ttda(s) + sizeof(uint16_t) * (4 + 3 * i) * width,
- MEMTXATTRS_UNSPECIFIED, s->data, size, false);
+ address_space_read(&s->as,
+ dp8393x_ttda(s)
+ + sizeof(uint16_t) * width * (4 + 3 * i),
+ MEMTXATTRS_UNSPECIFIED, s->data,
+ size);
s->regs[SONIC_TSA0] = dp8393x_get(s, width, 0);
s->regs[SONIC_TSA1] = dp8393x_get(s, width, 1);
s->regs[SONIC_TFS] = dp8393x_get(s, width, 2);
@@ -495,18 +496,18 @@ static void dp8393x_do_transmit_packets(dp8393xState *s)
dp8393x_put(s, width, 0,
s->regs[SONIC_TCR] & 0x0fff); /* status */
size = sizeof(uint16_t) * width;
- address_space_rw(&s->as,
- dp8393x_ttda(s),
- MEMTXATTRS_UNSPECIFIED, s->data, size, true);
+ address_space_write(&s->as, dp8393x_ttda(s),
+ MEMTXATTRS_UNSPECIFIED, s->data, size);
if (!(s->regs[SONIC_CR] & SONIC_CR_HTX)) {
/* Read footer of packet */
size = sizeof(uint16_t) * width;
- address_space_rw(&s->as,
- dp8393x_ttda(s) +
- sizeof(uint16_t) *
- (4 + 3 * s->regs[SONIC_TFC]) * width,
- MEMTXATTRS_UNSPECIFIED, s->data, size, false);
+ address_space_read(&s->as,
+ dp8393x_ttda(s)
+ + sizeof(uint16_t) * width
+ * (4 + 3 * s->regs[SONIC_TFC]),
+ MEMTXATTRS_UNSPECIFIED, s->data,
+ size);
s->regs[SONIC_CTDA] = dp8393x_get(s, width, 0) & ~0x1;
if (dp8393x_get(s, width, 0) & 0x1) {
/* EOL detected */
@@ -768,8 +769,8 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,
/* Are we still in resource exhaustion? */
size = sizeof(uint16_t) * 1 * width;
address = dp8393x_crda(s) + sizeof(uint16_t) * 5 * width;
- address_space_rw(&s->as, address, MEMTXATTRS_UNSPECIFIED,
- s->data, size, false);
+ address_space_read(&s->as, address, MEMTXATTRS_UNSPECIFIED,
+ s->data, size);
if (dp8393x_get(s, width, 0) & 0x1) {
/* Still EOL ; stop reception */
return -1;
@@ -788,10 +789,11 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,
/* Put packet into RBA */
DPRINTF("Receive packet at %08x\n", dp8393x_crba(s));
address = dp8393x_crba(s);
- address_space_write(&s->as, address, MEMTXATTRS_UNSPECIFIED, buf, rx_len);
+ address_space_write(&s->as, address, MEMTXATTRS_UNSPECIFIED,
+ buf, rx_len);
address += rx_len;
- address_space_rw(&s->as, address,
- MEMTXATTRS_UNSPECIFIED, &checksum, 4, true);
+ address_space_write(&s->as, address, MEMTXATTRS_UNSPECIFIED,
+ &checksum, 4);
rx_len += 4;
s->regs[SONIC_CRBA1] = address >> 16;
s->regs[SONIC_CRBA0] = address & 0xffff;
@@ -819,13 +821,15 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,
dp8393x_put(s, width, 3, s->regs[SONIC_TRBA1]); /* pkt_ptr1 */
dp8393x_put(s, width, 4, s->regs[SONIC_RSC]); /* seq_no */
size = sizeof(uint16_t) * 5 * width;
- address_space_rw(&s->as, dp8393x_crda(s),
- MEMTXATTRS_UNSPECIFIED, s->data, size, true);
+ address_space_write(&s->as, dp8393x_crda(s),
+ MEMTXATTRS_UNSPECIFIED,
+ s->data, size);
/* Move to next descriptor */
size = sizeof(uint16_t) * width;
- address_space_rw(&s->as, dp8393x_crda(s) + sizeof(uint16_t) * 5 * width,
- MEMTXATTRS_UNSPECIFIED, s->data, size, false);
+ address_space_read(&s->as,
+ dp8393x_crda(s) + sizeof(uint16_t) * 5 * width,
+ MEMTXATTRS_UNSPECIFIED, s->data, size);
s->regs[SONIC_LLFA] = dp8393x_get(s, width, 0);
if (s->regs[SONIC_LLFA] & 0x1) {
/* EOL detected */
@@ -838,8 +842,8 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,
offset += sizeof(uint16_t);
}
s->data[0] = 0;
- address_space_rw(&s->as, offset, MEMTXATTRS_UNSPECIFIED,
- s->data, sizeof(uint16_t), true);
+ address_space_write(&s->as, offset, MEMTXATTRS_UNSPECIFIED,
+ s->data, sizeof(uint16_t));
s->regs[SONIC_CRDA] = s->regs[SONIC_LLFA];
s->regs[SONIC_ISR] |= SONIC_ISR_PKTRX;
s->regs[SONIC_RSC] = (s->regs[SONIC_RSC] & 0xff00) | (((s->regs[SONIC_RSC] & 0x00ff) + 1) & 0x00ff);
diff --git a/hw/net/i82596.c b/hw/net/i82596.c
index 11537f72d1..fe9f2390a9 100644
--- a/hw/net/i82596.c
+++ b/hw/net/i82596.c
@@ -148,8 +148,8 @@ static void i82596_transmit(I82596State *s, uint32_t addr)
if (s->nic && len) {
assert(len <= sizeof(s->tx_buffer));
- address_space_rw(&address_space_memory, tba,
- MEMTXATTRS_UNSPECIFIED, s->tx_buffer, len, false);
+ address_space_read(&address_space_memory, tba,
+ MEMTXATTRS_UNSPECIFIED, s->tx_buffer, len);
DBG(PRINT_PKTHDR("Send", &s->tx_buffer));
DBG(printf("Sending %d bytes\n", len));
qemu_send_packet(qemu_get_queue(s->nic), s->tx_buffer, len);
@@ -172,8 +172,8 @@ static void set_individual_address(I82596State *s, uint32_t addr)
nc = qemu_get_queue(s->nic);
m = s->conf.macaddr.a;
- address_space_rw(&address_space_memory, addr + 8,
- MEMTXATTRS_UNSPECIFIED, m, ETH_ALEN, false);
+ address_space_read(&address_space_memory, addr + 8,
+ MEMTXATTRS_UNSPECIFIED, m, ETH_ALEN);
qemu_format_nic_info_str(nc, m);
trace_i82596_new_mac(nc->info_str);
}
@@ -190,9 +190,8 @@ static void set_multicast_list(I82596State *s, uint32_t addr)
}
for (i = 0; i < mc_count; i++) {
uint8_t multicast_addr[ETH_ALEN];
- address_space_rw(&address_space_memory,
- addr + i * ETH_ALEN, MEMTXATTRS_UNSPECIFIED,
- multicast_addr, ETH_ALEN, false);
+ address_space_read(&address_space_memory, addr + i * ETH_ALEN,
+ MEMTXATTRS_UNSPECIFIED, multicast_addr, ETH_ALEN);
DBG(printf("Add multicast entry " MAC_FMT "\n",
MAC_ARG(multicast_addr)));
unsigned mcast_idx = (net_crc32(multicast_addr, ETH_ALEN) &
@@ -260,9 +259,8 @@ static void command_loop(I82596State *s)
byte_cnt = MAX(byte_cnt, 4);
byte_cnt = MIN(byte_cnt, sizeof(s->config));
/* copy byte_cnt max. */
- address_space_rw(&address_space_memory, s->cmd_p + 8,
- MEMTXATTRS_UNSPECIFIED, s->config, byte_cnt,
- false);
+ address_space_read(&address_space_memory, s->cmd_p + 8,
+ MEMTXATTRS_UNSPECIFIED, s->config, byte_cnt);
/* config byte according to page 35ff */
s->config[2] &= 0x82; /* mask valid bits */
s->config[2] |= 0x40;
@@ -647,8 +645,8 @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz)
buf += num;
len -= num;
if (len == 0) { /* copy crc */
- address_space_rw(&address_space_memory, rba - 4,
- MEMTXATTRS_UNSPECIFIED, crc_ptr, 4, true);
+ address_space_write(&address_space_memory, rba - 4,
+ MEMTXATTRS_UNSPECIFIED, crc_ptr, 4);
}
num |= 0x4000; /* set F BIT */
diff --git a/hw/net/lasi_i82596.c b/hw/net/lasi_i82596.c
index 8bff419378..52637a562d 100644
--- a/hw/net/lasi_i82596.c
+++ b/hw/net/lasi_i82596.c
@@ -55,8 +55,9 @@ static void lasi_82596_mem_write(void *opaque, hwaddr addr,
* Provided for SeaBIOS only. Write MAC of Network card to addr @val.
* Needed for the PDC_LAN_STATION_ID_READ PDC call.
*/
- address_space_rw(&address_space_memory, val, MEMTXATTRS_UNSPECIFIED,
- d->state.conf.macaddr.a, ETH_ALEN, true);
+ address_space_write(&address_space_memory, val,
+ MEMTXATTRS_UNSPECIFIED, d->state.conf.macaddr.a,
+ ETH_ALEN);
break;
}
}
diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
index 5989d723c5..f150deca34 100644
--- a/hw/ppc/pnv_lpc.c
+++ b/hw/ppc/pnv_lpc.c
@@ -238,16 +238,16 @@ static bool opb_read(PnvLpcController *lpc, uint32_t addr, uint8_t *data,
int sz)
{
/* XXX Handle access size limits and FW read caching here */
- return !address_space_rw(&lpc->opb_as, addr, MEMTXATTRS_UNSPECIFIED,
- data, sz, false);
+ return !address_space_read(&lpc->opb_as, addr, MEMTXATTRS_UNSPECIFIED,
+ data, sz);
}
static bool opb_write(PnvLpcController *lpc, uint32_t addr, uint8_t *data,
int sz)
{
/* XXX Handle access size limits here */
- return !address_space_rw(&lpc->opb_as, addr, MEMTXATTRS_UNSPECIFIED,
- data, sz, true);
+ return !address_space_write(&lpc->opb_as, addr, MEMTXATTRS_UNSPECIFIED,
+ data, sz);
}
#define ECCB_CTL_READ PPC_BIT(15)
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index f27f8c45a5..5d8e08667e 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -874,18 +874,18 @@ static inline int ida_read_next_idaw(CcwDataStream *cds)
if (idaw_addr & 0x07 || !cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {
return -EINVAL; /* channel program check */
}
- ret = address_space_rw(&address_space_memory, idaw_addr,
- MEMTXATTRS_UNSPECIFIED, &idaw.fmt2,
- sizeof(idaw.fmt2), false);
+ ret = address_space_read(&address_space_memory, idaw_addr,
+ MEMTXATTRS_UNSPECIFIED, &idaw.fmt2,
+ sizeof(idaw.fmt2));
cds->cda = be64_to_cpu(idaw.fmt2);
} else {
idaw_addr = cds->cda_orig + sizeof(idaw.fmt1) * cds->at_idaw;
if (idaw_addr & 0x03 || !cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {
return -EINVAL; /* channel program check */
}
- ret = address_space_rw(&address_space_memory, idaw_addr,
- MEMTXATTRS_UNSPECIFIED, &idaw.fmt1,
- sizeof(idaw.fmt1), false);
+ ret = address_space_read(&address_space_memory, idaw_addr,
+ MEMTXATTRS_UNSPECIFIED, &idaw.fmt1,
+ sizeof(idaw.fmt1));
cds->cda = be64_to_cpu(idaw.fmt1);
if (cds->cda & 0x80000000) {
return -EINVAL; /* channel program check */
diff --git a/qtest.c b/qtest.c
index 65e33b80e3..dcb57498ad 100644
--- a/qtest.c
+++ b/qtest.c
@@ -429,23 +429,23 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
if (words[0][5] == 'b') {
uint8_t data = value;
- address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- &data, 1, true);
+ address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ &data, 1);
} else if (words[0][5] == 'w') {
uint16_t data = value;
tswap16s(&data);
- address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- &data, 2, true);
+ address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ &data, 2);
} else if (words[0][5] == 'l') {
uint32_t data = value;
tswap32s(&data);
- address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- &data, 4, true);
+ address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ &data, 4);
} else if (words[0][5] == 'q') {
uint64_t data = value;
tswap64s(&data);
- address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- &data, 8, true);
+ address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ &data, 8);
}
qtest_send_prefix(chr);
qtest_send(chr, "OK\n");
@@ -463,22 +463,22 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
if (words[0][4] == 'b') {
uint8_t data;
- address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- &data, 1, false);
+ address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ &data, 1);
value = data;
} else if (words[0][4] == 'w') {
uint16_t data;
- address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- &data, 2, false);
+ address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ &data, 2);
value = tswap16(data);
} else if (words[0][4] == 'l') {
uint32_t data;
- address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- &data, 4, false);
+ address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ &data, 4);
value = tswap32(data);
} else if (words[0][4] == 'q') {
- address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- &value, 8, false);
+ address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ &value, 8);
tswap64s(&value);
}
qtest_send_prefix(chr);
@@ -498,8 +498,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
g_assert(len);
data = g_malloc(len);
- address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- data, len, false);
+ address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
+ len);
enc = g_malloc(2 * len + 1);
for (i = 0; i < len; i++) {
@@ -524,8 +524,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
g_assert(ret == 0);
data = g_malloc(len);
- address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- data, len, false);
+ address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
+ len);
b64_data = g_base64_encode(data, len);
qtest_send_prefix(chr);
qtest_sendf(chr, "OK %s\n", b64_data);
@@ -559,8 +559,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
data[i] = 0;
}
}
- address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- data, len, true);
+ address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
+ len);
g_free(data);
qtest_send_prefix(chr);
@@ -582,8 +582,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
if (len) {
data = g_malloc(len);
memset(data, pattern, len);
- address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- data, len, true);
+ address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ data, len);
g_free(data);
}
@@ -616,8 +616,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
out_len = MIN(out_len, len);
}
- address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- data, len, true);
+ address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
+ len);
qtest_send_prefix(chr);
qtest_send(chr, "OK\n");
diff --git a/target/i386/hvf/x86_mmu.c b/target/i386/hvf/x86_mmu.c
index 451dcc983a..65d4603dbf 100644
--- a/target/i386/hvf/x86_mmu.c
+++ b/target/i386/hvf/x86_mmu.c
@@ -88,8 +88,8 @@ static bool get_pt_entry(struct CPUState *cpu, struct gpt_translation *pt,
}
index = gpt_entry(pt->gva, level, pae);
- address_space_rw(&address_space_memory, gpa + index * pte_size(pae),
- MEMTXATTRS_UNSPECIFIED, &pte, pte_size(pae), false);
+ address_space_read(&address_space_memory, gpa + index * pte_size(pae),
+ MEMTXATTRS_UNSPECIFIED, &pte, pte_size(pae));
pt->pte[level - 1] = pte;
@@ -238,8 +238,8 @@ void vmx_write_mem(struct CPUState *cpu, target_ulong gva, void *data, int bytes
if (!mmu_gva_to_gpa(cpu, gva, &gpa)) {
VM_PANIC_EX("%s: mmu_gva_to_gpa %llx failed\n", __func__, gva);
} else {
- address_space_rw(&address_space_memory, gpa,
- MEMTXATTRS_UNSPECIFIED, data, copy, true);
+ address_space_write(&address_space_memory, gpa,
+ MEMTXATTRS_UNSPECIFIED, data, copy);
}
bytes -= copy;
@@ -259,8 +259,8 @@ void vmx_read_mem(struct CPUState *cpu, void *data, target_ulong gva, int bytes)
if (!mmu_gva_to_gpa(cpu, gva, &gpa)) {
VM_PANIC_EX("%s: mmu_gva_to_gpa %llx failed\n", __func__, gva);
}
- address_space_rw(&address_space_memory, gpa, MEMTXATTRS_UNSPECIFIED,
- data, copy, false);
+ address_space_read(&address_space_memory, gpa, MEMTXATTRS_UNSPECIFIED,
+ data, copy);
bytes -= copy;
gva += copy;
--
2.21.1
^ permalink raw reply related
* Re: [Xen-devel] [PATCH v3 03/20] exec: Let qemu_ram_*() functions take a const pointer argument
From: Paolo Bonzini @ 2020-02-20 13:21 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Peter Maydell, qemu-devel
Cc: Fam Zheng, Dmitry Fleytman, kvm, Michael S. Tsirkin, Jason Wang,
Gerd Hoffmann, Edgar E. Iglesias, Stefano Stabellini,
Matthew Rosato, qemu-block, David Hildenbrand, Halil Pasic,
Christian Borntraeger, Hervé Poussineau, Marcel Apfelbaum,
Anthony Perard, xen-devel, Aleksandar Rikalo, Richard Henderson,
Laurent Vivier, Thomas Huth, Eduardo Habkost, Stefan Weil,
Alistair Francis, Richard Henderson, Paul Durrant, Eric Auger,
qemu-s390x, qemu-arm, Cédric Le Goater, John Snow,
David Gibson, Igor Mitsyanko, Cornelia Huck, Michael Walle,
qemu-ppc
In-Reply-To: <20200220130548.29974-4-philmd@redhat.com>
On 20/02/20 14:05, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> include/exec/cpu-common.h | 6 +++---
> include/sysemu/xen-mapcache.h | 4 ++--
> exec.c | 8 ++++----
> hw/i386/xen/xen-mapcache.c | 2 +-
> 4 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
> index 81753bbb34..05ac1a5d69 100644
> --- a/include/exec/cpu-common.h
> +++ b/include/exec/cpu-common.h
> @@ -48,11 +48,11 @@ typedef uint32_t CPUReadMemoryFunc(void *opaque, hwaddr addr);
>
> void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
> /* This should not be used by devices. */
> -ram_addr_t qemu_ram_addr_from_host(void *ptr);
> +ram_addr_t qemu_ram_addr_from_host(const void *ptr);
This is a bit ugly, because the pointer _can_ be modified via
qemu_map_ram_ptr. Is this needed for the rest of the series to apply?
Paolo
> RAMBlock *qemu_ram_block_by_name(const char *name);
> -RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
> +RAMBlock *qemu_ram_block_from_host(const void *ptr, bool round_offset,
> ram_addr_t *offset);
> -ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host);
> +ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, const void *host);
> void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
> void qemu_ram_unset_idstr(RAMBlock *block);
> const char *qemu_ram_get_idstr(RAMBlock *rb);
> diff --git a/include/sysemu/xen-mapcache.h b/include/sysemu/xen-mapcache.h
> index c8e7c2f6cf..81e9aa2fa6 100644
> --- a/include/sysemu/xen-mapcache.h
> +++ b/include/sysemu/xen-mapcache.h
> @@ -19,7 +19,7 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f,
> void *opaque);
> uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size,
> uint8_t lock, bool dma);
> -ram_addr_t xen_ram_addr_from_mapcache(void *ptr);
> +ram_addr_t xen_ram_addr_from_mapcache(const void *ptr);
> void xen_invalidate_map_cache_entry(uint8_t *buffer);
> void xen_invalidate_map_cache(void);
> uint8_t *xen_replace_cache_entry(hwaddr old_phys_addr,
> @@ -40,7 +40,7 @@ static inline uint8_t *xen_map_cache(hwaddr phys_addr,
> abort();
> }
>
> -static inline ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
> +static inline ram_addr_t xen_ram_addr_from_mapcache(const void *ptr)
> {
> abort();
> }
> diff --git a/exec.c b/exec.c
> index 8e9cc3b47c..02b4e6ea41 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -2614,7 +2614,7 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr,
> }
>
> /* Return the offset of a hostpointer within a ramblock */
> -ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host)
> +ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, const void *host)
> {
> ram_addr_t res = (uint8_t *)host - (uint8_t *)rb->host;
> assert((uintptr_t)host >= (uintptr_t)rb->host);
> @@ -2640,11 +2640,11 @@ ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host)
> * pointer, such as a reference to the region that includes the incoming
> * ram_addr_t.
> */
> -RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
> +RAMBlock *qemu_ram_block_from_host(const void *ptr, bool round_offset,
> ram_addr_t *offset)
> {
> RAMBlock *block;
> - uint8_t *host = ptr;
> + const uint8_t *host = ptr;
>
> if (xen_enabled()) {
> ram_addr_t ram_addr;
> @@ -2705,7 +2705,7 @@ RAMBlock *qemu_ram_block_by_name(const char *name)
>
> /* Some of the softmmu routines need to translate from a host pointer
> (typically a TLB entry) back to a ram offset. */
> -ram_addr_t qemu_ram_addr_from_host(void *ptr)
> +ram_addr_t qemu_ram_addr_from_host(const void *ptr)
> {
> RAMBlock *block;
> ram_addr_t offset;
> diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c
> index 5b120ed44b..432ad3354d 100644
> --- a/hw/i386/xen/xen-mapcache.c
> +++ b/hw/i386/xen/xen-mapcache.c
> @@ -363,7 +363,7 @@ uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size,
> return p;
> }
>
> -ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
> +ram_addr_t xen_ram_addr_from_mapcache(const void *ptr)
> {
> MapCacheEntry *entry = NULL;
> MapCacheRev *reventry;
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply
* Re: [PATCH 2/3] bcache: make bch_btree_check() to be multiple threads
From: Coly Li @ 2020-02-20 13:21 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-bcache, linux-block
In-Reply-To: <20200219163015.GE10644@infradead.org>
On 2020/2/20 12:30 上午, Christoph Hellwig wrote:
> maybe s/be multiple threads/multithreaded/ in the subject?
>
Sure, I will do it in next version.
Thanks.
--
Coly Li
^ permalink raw reply
* Re: [PATCH v3 03/20] exec: Let qemu_ram_*() functions take a const pointer argument
From: Paolo Bonzini @ 2020-02-20 13:21 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Peter Maydell, qemu-devel
Cc: Edgar E. Iglesias, Anthony Perard, Fam Zheng,
Hervé Poussineau, kvm, Laurent Vivier, Thomas Huth,
Stefan Weil, Eric Auger, Halil Pasic, Marcel Apfelbaum,
qemu-s390x, Aleksandar Rikalo, David Gibson, Michael Walle,
qemu-ppc, Gerd Hoffmann, Cornelia Huck, qemu-arm,
Alistair Francis, qemu-block, Cédric Le Goater, Jason Wang,
xen-devel, Christian Borntraeger, Dmitry Fleytman, Matthew Rosato,
Eduardo Habkost, Richard Henderson, Michael S. Tsirkin,
David Hildenbrand, Stefano Stabellini, Igor Mitsyanko,
Paul Durrant, Richard Henderson, John Snow
In-Reply-To: <20200220130548.29974-4-philmd@redhat.com>
On 20/02/20 14:05, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> include/exec/cpu-common.h | 6 +++---
> include/sysemu/xen-mapcache.h | 4 ++--
> exec.c | 8 ++++----
> hw/i386/xen/xen-mapcache.c | 2 +-
> 4 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
> index 81753bbb34..05ac1a5d69 100644
> --- a/include/exec/cpu-common.h
> +++ b/include/exec/cpu-common.h
> @@ -48,11 +48,11 @@ typedef uint32_t CPUReadMemoryFunc(void *opaque, hwaddr addr);
>
> void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
> /* This should not be used by devices. */
> -ram_addr_t qemu_ram_addr_from_host(void *ptr);
> +ram_addr_t qemu_ram_addr_from_host(const void *ptr);
This is a bit ugly, because the pointer _can_ be modified via
qemu_map_ram_ptr. Is this needed for the rest of the series to apply?
Paolo
> RAMBlock *qemu_ram_block_by_name(const char *name);
> -RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
> +RAMBlock *qemu_ram_block_from_host(const void *ptr, bool round_offset,
> ram_addr_t *offset);
> -ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host);
> +ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, const void *host);
> void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
> void qemu_ram_unset_idstr(RAMBlock *block);
> const char *qemu_ram_get_idstr(RAMBlock *rb);
> diff --git a/include/sysemu/xen-mapcache.h b/include/sysemu/xen-mapcache.h
> index c8e7c2f6cf..81e9aa2fa6 100644
> --- a/include/sysemu/xen-mapcache.h
> +++ b/include/sysemu/xen-mapcache.h
> @@ -19,7 +19,7 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f,
> void *opaque);
> uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size,
> uint8_t lock, bool dma);
> -ram_addr_t xen_ram_addr_from_mapcache(void *ptr);
> +ram_addr_t xen_ram_addr_from_mapcache(const void *ptr);
> void xen_invalidate_map_cache_entry(uint8_t *buffer);
> void xen_invalidate_map_cache(void);
> uint8_t *xen_replace_cache_entry(hwaddr old_phys_addr,
> @@ -40,7 +40,7 @@ static inline uint8_t *xen_map_cache(hwaddr phys_addr,
> abort();
> }
>
> -static inline ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
> +static inline ram_addr_t xen_ram_addr_from_mapcache(const void *ptr)
> {
> abort();
> }
> diff --git a/exec.c b/exec.c
> index 8e9cc3b47c..02b4e6ea41 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -2614,7 +2614,7 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr,
> }
>
> /* Return the offset of a hostpointer within a ramblock */
> -ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host)
> +ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, const void *host)
> {
> ram_addr_t res = (uint8_t *)host - (uint8_t *)rb->host;
> assert((uintptr_t)host >= (uintptr_t)rb->host);
> @@ -2640,11 +2640,11 @@ ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host)
> * pointer, such as a reference to the region that includes the incoming
> * ram_addr_t.
> */
> -RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
> +RAMBlock *qemu_ram_block_from_host(const void *ptr, bool round_offset,
> ram_addr_t *offset)
> {
> RAMBlock *block;
> - uint8_t *host = ptr;
> + const uint8_t *host = ptr;
>
> if (xen_enabled()) {
> ram_addr_t ram_addr;
> @@ -2705,7 +2705,7 @@ RAMBlock *qemu_ram_block_by_name(const char *name)
>
> /* Some of the softmmu routines need to translate from a host pointer
> (typically a TLB entry) back to a ram offset. */
> -ram_addr_t qemu_ram_addr_from_host(void *ptr)
> +ram_addr_t qemu_ram_addr_from_host(const void *ptr)
> {
> RAMBlock *block;
> ram_addr_t offset;
> diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c
> index 5b120ed44b..432ad3354d 100644
> --- a/hw/i386/xen/xen-mapcache.c
> +++ b/hw/i386/xen/xen-mapcache.c
> @@ -363,7 +363,7 @@ uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size,
> return p;
> }
>
> -ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
> +ram_addr_t xen_ram_addr_from_mapcache(const void *ptr)
> {
> MapCacheEntry *entry = NULL;
> MapCacheRev *reventry;
>
^ permalink raw reply
* Re: [PATCH 1/3] bcache: move macro btree() and btree_root() into btree.h
From: Coly Li @ 2020-02-20 13:21 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-bcache, linux-block
In-Reply-To: <20200219162945.GD10644@infradead.org>
On 2020/2/20 12:29 上午, Christoph Hellwig wrote:
> On Sat, Feb 15, 2020 at 04:28:56PM +0800, Coly Li wrote:
>> In order to accelerate bcache registration speed, the macro btree()
>> and btree_root() will be referenced out of btree.c. This patch moves
>> them from btree.c into btree.h with other relative function declaration
>> in btree.h, for the following changes.
>
> Can you give them a bcache_ prefix? That names are awfully generic
> and bound to clash sooner or later.
>
Sure I will do it in next version.
Thanks.
--
Coly Li
^ permalink raw reply
* Re: [Intel-gfx] [PATCH 00/12] drm: Put drm_display_mode on diet
From: Emil Velikov @ 2020-02-20 13:21 UTC (permalink / raw)
To: Ville Syrjala; +Cc: Intel Graphics Development, ML dri-devel
In-Reply-To: <20200219203544.31013-1-ville.syrjala@linux.intel.com>
On Wed, 19 Feb 2020 at 20:35, Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> struct drm_display_mode is extremely fat. Put it on diet.
>
> Some stats for the whole series:
>
> 64bit sizeof(struct drm_display_mode):
> 200 -> 136 bytes (-32%)
>
> 64bit bloat-o-meter -c drm.ko:
> add/remove: 1/0 grow/shrink: 29/47 up/down: 893/-1544 (-651)
> Function old new delta
> ...
> Total: Before=189430, After=188779, chg -0.34%
> add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0)
> Data old new delta
> Total: Before=11667, After=11667, chg +0.00%
> add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-16896 (-16896)
> RO Data old new delta
> edid_4k_modes 1000 680 -320
> edid_est_modes 3400 2312 -1088
> edid_cea_modes_193 5400 3672 -1728
> drm_dmt_modes 17600 11968 -5632
> edid_cea_modes_1 25400 17272 -8128
> Total: Before=71239, After=54343, chg -23.72%
>
>
> 64bit bloat-o-meter drm.ko:
> add/remove: 1/0 grow/shrink: 29/52 up/down: 893/-18440 (-17547)
> ...
> Total: Before=272336, After=254789, chg -6.44%
>
>
> 32bit sizeof(struct drm_display_mode):
> 184 -> 120 bytes (-34%)
>
> 32bit bloat-o-meter -c drm.ko
> add/remove: 1/0 grow/shrink: 19/21 up/down: 743/-1368 (-625)
> Function old new delta
> ...
> Total: Before=172359, After=171734, chg -0.36%
> add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0)
> Data old new delta
> Total: Before=4227, After=4227, chg +0.00%
> add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-16896 (-16896)
> RO Data old new delta
> edid_4k_modes 920 600 -320
> edid_est_modes 3128 2040 -1088
> edid_cea_modes_193 4968 3240 -1728
> drm_dmt_modes 16192 10560 -5632
> edid_cea_modes_1 23368 15240 -8128
> Total: Before=59230, After=42334, chg -28.53%
>
> 32bit bloat-o-meter drm.ko:
> add/remove: 1/0 grow/shrink: 19/26 up/down: 743/-18264 (-17521)
> ...
> Total: Before=235816, After=218295, chg -7.43%
>
>
> Some ideas for further reduction:
> - Convert mode->name to a pointer (saves 24/28 bytes in the
> struct but would often require a heap alloc for the name (though
> typical mode name is <10 bytes so still overall win perhaps)
> - Get rid of mode->name entirely? I guess setcrtc & co. is the only
> place where we have to preserve the user provided name, elsewhere
> could pehaps just generate on demand? Not sure how tricky this
> would get.
The series does some great work, with future work reaching the cache
line for 64bit.
Doing much more than that might be an overkill IMHO.
In particular, if we change DRM_DISPLAY_MODE_LEN to 24 we get there,
avoiding the heap alloc/calc on demand fun.
While also ensuring the name is sufficiently large for the next decade or so.
From drm_mode_set_name():
snprintf(mode->name, DRM_DISPLAY_MODE_LEN, "%dx%d%s",
mode->hdisplay, mode->vdisplay, interlaced ? "i" : "");
We change the h/v display from (10^15)-1 to (10^11)-1 which seems reasonable.
Note: haven't checked if name includes the terminating \0, so take
numbers with a grain of salt.
-Emil
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply
* Re: [PATCH bpf-next v4 2/3] libbpf: Add support for dynamic program attach target
From: Eelco Chaudron @ 2020-02-20 13:21 UTC (permalink / raw)
To: Andrii Nakryiko
Cc: Jakub Sitnicki, bpf, David S. Miller, Networking,
Alexei Starovoitov, Daniel Borkmann, Martin Lau, Song Liu,
Yonghong Song, Andrii Nakryiko, Toke Høiland-Jørgensen
In-Reply-To: <CAEf4BzY3cwPvj9=wo_GJxN=1=5fJL1RuhjEfey3N09GOL0YYfw@mail.gmail.com>
On 19 Feb 2020, at 18:41, Andrii Nakryiko wrote:
> On Wed, Feb 19, 2020 at 3:06 AM Eelco Chaudron <echaudro@redhat.com> wrote:
>>
>>
>>
>> On 18 Feb 2020, at 22:24, Andrii Nakryiko wrote:
>>
>>> On Tue, Feb 18, 2020 at 8:34 AM Jakub Sitnicki <jakub@cloudflare.com>
>>> wrote:
>>>>
>>>> Hey Eelco,
>>>>
>>>> On Mon, Feb 17, 2020 at 12:43 PM GMT, Eelco Chaudron wrote:
>>>>> Currently when you want to attach a trace program to a bpf program
>>>>> the section name needs to match the tracepoint/function semantics.
>>>>>
>>>>> However the addition of the bpf_program__set_attach_target() API
>>>>> allows you to specify the tracepoint/function dynamically.
>>>>>
>>>>> The call flow would look something like this:
>>>>>
>>>>> xdp_fd = bpf_prog_get_fd_by_id(id);
>>>>> trace_obj = bpf_object__open_file("func.o", NULL);
>>>>> prog = bpf_object__find_program_by_title(trace_obj,
>>>>> "fentry/myfunc");
>>>>> bpf_program__set_expected_attach_type(prog, BPF_TRACE_FENTRY);
>>>>> bpf_program__set_attach_target(prog, xdp_fd,
>>>>> "xdpfilt_blk_all");
>>>>> bpf_object__load(trace_obj)
>>>>>
>>>>> Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
>>>>> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
>>>>> ---
>>>>> tools/lib/bpf/libbpf.c | 34 ++++++++++++++++++++++++++++++----
>>>>> tools/lib/bpf/libbpf.h | 4 ++++
>>>>> tools/lib/bpf/libbpf.map | 2 ++
>>>>> 3 files changed, 36 insertions(+), 4 deletions(-)
>>>>>
>>>>> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
>>>>> index 514b1a524abb..0c25d78fb5d8 100644
>>>>> --- a/tools/lib/bpf/libbpf.c
>>>>> +++ b/tools/lib/bpf/libbpf.c
>>>>
>>>> [...]
>>>>
>>>>> @@ -8132,6 +8133,31 @@ void bpf_program__bpil_offs_to_addr(struct
>>>>> bpf_prog_info_linear *info_linear)
>>>>> }
>>>>> }
>>>>>
>>>>> +int bpf_program__set_attach_target(struct bpf_program *prog,
>>>>> + int attach_prog_fd,
>>>>> + const char *attach_func_name)
>>>>> +{
>>>>> + int btf_id;
>>>>> +
>>>>> + if (!prog || attach_prog_fd < 0 || !attach_func_name)
>>>>> + return -EINVAL;
>>>>> +
>>>>> + if (attach_prog_fd)
>>>>> + btf_id = libbpf_find_prog_btf_id(attach_func_name,
>>>>> + attach_prog_fd);
>>>>> + else
>>>>> + btf_id = __find_vmlinux_btf_id(prog->obj->btf_vmlinux,
>>>>> + attach_func_name,
>>>>> +
>>>>> prog->expected_attach_type);
>>>>> +
>>>>> + if (btf_id <= 0)
>>>>> + return btf_id;
>>>>
>>>> Looks like we can get 0 as return value on both error and success
>>>> (below)? Is that intentional?
>>>
>>> Neither libbpf_find_prog_btf_id nor __find_vmlinux_btf_id are going to
>>> return 0 on failure. But I do agree that if (btf_id < 0) check would
>>> be better here.
>>
>> Is see in theory btf__find_by_name_kind() could return 0:
>>
>> if (kind == BTF_KIND_UNKN || !strcmp(type_name, "void"))
>> return 0;
>>
>> But for our case, this will not happen and is invalid, so what about
>> just to make sure its future proof?:
>>
>> if (btf_id <= 0)
>> return btf_id ? btf_id : -ENOENT;
>
> I don't see how void can be the right attach type, so I'd keep it
> simple: if (btf_id < 0) return btf_id.
> If it so happens that 0 is returned, it will fail at attach time anyways.
Ok, will send out a v5 later today…
>>> With that minor nit:
>>>
>>> Acked-by: Andrii Nakryiko <andriin@fb.com>
>>>
>>>>
>>>>> +
>>>>> + prog->attach_btf_id = btf_id;
>>>>> + prog->attach_prog_fd = attach_prog_fd;
>>>>> + return 0;
>>>>> +}
>>>>> +
>>>>> int parse_cpu_mask_str(const char *s, bool **mask, int *mask_sz)
>>>>> {
>>>>> int err = 0, n, len, start, end = -1;
>>>>
>>>> [...]
>>
^ permalink raw reply
* Re: [PATCH 00/12] drm: Put drm_display_mode on diet
From: Emil Velikov @ 2020-02-20 13:21 UTC (permalink / raw)
To: Ville Syrjala; +Cc: Intel Graphics Development, ML dri-devel
In-Reply-To: <20200219203544.31013-1-ville.syrjala@linux.intel.com>
On Wed, 19 Feb 2020 at 20:35, Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> struct drm_display_mode is extremely fat. Put it on diet.
>
> Some stats for the whole series:
>
> 64bit sizeof(struct drm_display_mode):
> 200 -> 136 bytes (-32%)
>
> 64bit bloat-o-meter -c drm.ko:
> add/remove: 1/0 grow/shrink: 29/47 up/down: 893/-1544 (-651)
> Function old new delta
> ...
> Total: Before=189430, After=188779, chg -0.34%
> add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0)
> Data old new delta
> Total: Before=11667, After=11667, chg +0.00%
> add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-16896 (-16896)
> RO Data old new delta
> edid_4k_modes 1000 680 -320
> edid_est_modes 3400 2312 -1088
> edid_cea_modes_193 5400 3672 -1728
> drm_dmt_modes 17600 11968 -5632
> edid_cea_modes_1 25400 17272 -8128
> Total: Before=71239, After=54343, chg -23.72%
>
>
> 64bit bloat-o-meter drm.ko:
> add/remove: 1/0 grow/shrink: 29/52 up/down: 893/-18440 (-17547)
> ...
> Total: Before=272336, After=254789, chg -6.44%
>
>
> 32bit sizeof(struct drm_display_mode):
> 184 -> 120 bytes (-34%)
>
> 32bit bloat-o-meter -c drm.ko
> add/remove: 1/0 grow/shrink: 19/21 up/down: 743/-1368 (-625)
> Function old new delta
> ...
> Total: Before=172359, After=171734, chg -0.36%
> add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0)
> Data old new delta
> Total: Before=4227, After=4227, chg +0.00%
> add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-16896 (-16896)
> RO Data old new delta
> edid_4k_modes 920 600 -320
> edid_est_modes 3128 2040 -1088
> edid_cea_modes_193 4968 3240 -1728
> drm_dmt_modes 16192 10560 -5632
> edid_cea_modes_1 23368 15240 -8128
> Total: Before=59230, After=42334, chg -28.53%
>
> 32bit bloat-o-meter drm.ko:
> add/remove: 1/0 grow/shrink: 19/26 up/down: 743/-18264 (-17521)
> ...
> Total: Before=235816, After=218295, chg -7.43%
>
>
> Some ideas for further reduction:
> - Convert mode->name to a pointer (saves 24/28 bytes in the
> struct but would often require a heap alloc for the name (though
> typical mode name is <10 bytes so still overall win perhaps)
> - Get rid of mode->name entirely? I guess setcrtc & co. is the only
> place where we have to preserve the user provided name, elsewhere
> could pehaps just generate on demand? Not sure how tricky this
> would get.
The series does some great work, with future work reaching the cache
line for 64bit.
Doing much more than that might be an overkill IMHO.
In particular, if we change DRM_DISPLAY_MODE_LEN to 24 we get there,
avoiding the heap alloc/calc on demand fun.
While also ensuring the name is sufficiently large for the next decade or so.
From drm_mode_set_name():
snprintf(mode->name, DRM_DISPLAY_MODE_LEN, "%dx%d%s",
mode->hdisplay, mode->vdisplay, interlaced ? "i" : "");
We change the h/v display from (10^15)-1 to (10^11)-1 which seems reasonable.
Note: haven't checked if name includes the terminating \0, so take
numbers with a grain of salt.
-Emil
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply
* Re: [PATCH 1/3] bcache: ignore pending signals when creating gc and allocator thread
From: Coly Li @ 2020-02-20 13:20 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: axboe, linux-bcache, linux-block
In-Reply-To: <20200219163200.GA18377@infradead.org>
On 2020/2/20 12:32 上午, Christoph Hellwig wrote:
> On Thu, Feb 13, 2020 at 10:12:05PM +0800, Coly Li wrote:
>> + /*
>> + * In case previous btree check operation occupies too many
>> + * system memory for bcache btree node cache, and the
>> + * registering process is selected by OOM killer. Here just
>> + * ignore the SIGKILL sent by OOM killer if there is, to
>> + * avoid kthread_run() being failed by pending signals. The
>> + * bcache registering process will exit after the registration
>> + * done.
>> + */
>> + if (signal_pending(current))
>> + flush_signals(current);
>> +
>> + k = kthread_run(bch_allocator_thread, ca, "bcache_allocator");
>
> This really needs to go into the kthread code itself instead of
> requiring cargo culting in the callers.
>
Hi Christoph,
Correct me if I am wrong.
If the signal is set before calling kthread_run(), kthread_run() will
fail and return -EINTR as code comment of __kthread_create_on_node() says,
315 /*
316 * Wait for completion in killable state, for I might be chosen by
317 * the OOM killer while kthreadd is trying to allocate memory for
318 * new kernel thread.
319 */
320 if (unlikely(wait_for_completion_killable(&done))) {
321 /*
322 * If I was SIGKILLed before kthreadd (or new kernel thread)
323 * calls complete(), leave the cleanup of this structure to
324 * that thread.
325 */
326 if (xchg(&create->done, NULL))
327 return ERR_PTR(-EINTR);
328 /*
329 * kthreadd (or new kernel thread) will call complete()
330 * shortly.
331 */
332 wait_for_completion(&done);
333 }
So the caller of kthread_run(), in this case it is
bch_cache_allocator_start() will receive -EINTR, and returns error to
its caller bch_cache_set_alloc(). Then the registration will fail and
ignore what the kthread routine does in parallel.
Therefore I need to explicitly call pending_signal() before calling
kthread_run().
--
Coly Li
^ permalink raw reply
* Patchwork housekeeping for: linux-renesas-soc
From: patchwork-bot+linux-renesas-soc @ 2020-02-20 13:20 UTC (permalink / raw)
To: linux-renesas-soc
Latest series: [v2] gpio: of: Add DT overlay support for GPIO hogs (2020-02-20T13:01:47)
Superseding: [v1] gpio: of: Add DT overlay support for GPIO hogs (2019-12-30T13:38:50):
[PATCH/RFC,1/2] gpio: of: Extract of_gpiochip_add_hog()
[PATCH/RFC,2/2] gpio: of: Add DT overlay support for GPIO hogs
--
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/pwbot
^ permalink raw reply
* [PATCH] USB: Replace zero-length array with flexible-array member
From: Gustavo A. R. Silva @ 2020-02-20 13:20 UTC (permalink / raw)
To: Greg Kroah-Hartman, Minas Harutyunyan, Alan Stern, Thierry Reding,
Jonathan Hunter, Mathias Nyman, Matthias Brugger, Johan Hovold,
Felipe Balbi
Cc: linux-usb, linux-kernel, linux-tegra, linux-arm-kernel,
linux-mediatek, Gustavo A. R. Silva
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:
struct foo {
int stuff;
struct boo array[];
};
By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.
Also, notice that, dynamic memory allocations won't be affected by
this change:
"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]
This issue was found with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/usb/atm/usbatm.h | 2 +-
drivers/usb/dwc2/hcd.h | 2 +-
drivers/usb/host/ehci-tegra.c | 2 +-
drivers/usb/host/ehci.h | 4 ++--
drivers/usb/host/fotg210.h | 2 +-
drivers/usb/host/ohci.h | 4 ++--
drivers/usb/host/xhci-mtk.h | 2 +-
drivers/usb/host/xhci.h | 4 ++--
drivers/usb/serial/io_usbvend.h | 4 ++--
drivers/usb/serial/ti_usb_3410_5052.c | 4 ++--
include/linux/usb.h | 4 ++--
include/linux/usb/audio-v2.h | 2 +-
include/linux/usb/audio-v3.h | 2 +-
include/linux/usb/gadget.h | 2 +-
include/linux/usb/hcd.h | 2 +-
include/linux/usbdevice_fs.h | 2 +-
16 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h
index d3bdc4cc47aa..8725755bd53d 100644
--- a/drivers/usb/atm/usbatm.h
+++ b/drivers/usb/atm/usbatm.h
@@ -164,7 +164,7 @@ struct usbatm_data {
unsigned char *cell_buf; /* holds partial rx cell */
unsigned int buf_usage;
- struct urb *urbs[0];
+ struct urb *urbs[];
};
static inline void *to_usbatm_driver_data(struct usb_interface *intf)
diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h
index 8ca6d12a6f57..1224fa9df604 100644
--- a/drivers/usb/dwc2/hcd.h
+++ b/drivers/usb/dwc2/hcd.h
@@ -199,7 +199,7 @@ struct dwc2_hcd_urb {
u32 flags;
u16 interval;
struct dwc2_hcd_pipe_info pipe_info;
- struct dwc2_hcd_iso_packet_desc iso_descs[0];
+ struct dwc2_hcd_iso_packet_desc iso_descs[];
};
/* Phases for control transfers */
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index d6433f206c17..10d51daa6a1b 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -282,7 +282,7 @@ static int tegra_ehci_hub_control(
struct dma_aligned_buffer {
void *kmalloc_ptr;
void *old_xfer_buffer;
- u8 data[0];
+ u8 data[];
};
static void free_dma_aligned_buffer(struct urb *urb)
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index ac5e967907d1..229b3de319e6 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -255,7 +255,7 @@ struct ehci_hcd { /* one per controller */
struct list_head tt_list;
/* platform-specific data -- must come last */
- unsigned long priv[0] __aligned(sizeof(s64));
+ unsigned long priv[] __aligned(sizeof(s64));
};
/* convert between an HCD pointer and the corresponding EHCI_HCD */
@@ -460,7 +460,7 @@ struct ehci_iso_sched {
struct list_head td_list;
unsigned span;
unsigned first_packet;
- struct ehci_iso_packet packet[0];
+ struct ehci_iso_packet packet[];
};
/*
diff --git a/drivers/usb/host/fotg210.h b/drivers/usb/host/fotg210.h
index 1b4db95e5c43..6cee40ec65b4 100644
--- a/drivers/usb/host/fotg210.h
+++ b/drivers/usb/host/fotg210.h
@@ -490,7 +490,7 @@ struct fotg210_iso_packet {
struct fotg210_iso_sched {
struct list_head td_list;
unsigned span;
- struct fotg210_iso_packet packet[0];
+ struct fotg210_iso_packet packet[];
};
/*
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
index b015b00774b2..27c26ca10bfd 100644
--- a/drivers/usb/host/ohci.h
+++ b/drivers/usb/host/ohci.h
@@ -337,7 +337,7 @@ typedef struct urb_priv {
u16 length; // # tds in this request
u16 td_cnt; // tds already serviced
struct list_head pending;
- struct td *td [0]; // all TDs in this request
+ struct td *td[]; // all TDs in this request
} urb_priv_t;
@@ -435,7 +435,7 @@ struct ohci_hcd {
struct dentry *debug_dir;
/* platform-specific data -- must come last */
- unsigned long priv[0] __aligned(sizeof(s64));
+ unsigned long priv[] __aligned(sizeof(s64));
};
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 5ac458b7d2e0..acd56517215a 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -95,7 +95,7 @@ struct mu3h_sch_ep_info {
u32 pkts;
u32 cs_count;
u32 burst_mode;
- u32 bw_budget_table[0];
+ u32 bw_budget_table[];
};
#define MU3C_U3_PORT_MAX 4
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 3ecee10fdcdc..685180e1b98a 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1642,7 +1642,7 @@ struct xhci_scratchpad {
struct urb_priv {
int num_tds;
int num_tds_done;
- struct xhci_td td[0];
+ struct xhci_td td[];
};
/*
@@ -1901,7 +1901,7 @@ struct xhci_hcd {
void *dbc;
/* platform-specific data -- must come last */
- unsigned long priv[0] __aligned(sizeof(s64));
+ unsigned long priv[] __aligned(sizeof(s64));
};
/* Platform specific overrides to generic XHCI hc_driver ops */
diff --git a/drivers/usb/serial/io_usbvend.h b/drivers/usb/serial/io_usbvend.h
index c38e87ac5ea9..0d1a5bb4636e 100644
--- a/drivers/usb/serial/io_usbvend.h
+++ b/drivers/usb/serial/io_usbvend.h
@@ -593,7 +593,7 @@ struct ti_i2c_desc {
__u8 Type; // Type of descriptor
__le16 Size; // Size of data only not including header
__u8 CheckSum; // Checksum (8 bit sum of data only)
- __u8 Data[0]; // Data starts here
+ __u8 Data[]; // Data starts here
} __attribute__((packed));
// for 5152 devices only (type 2 record)
@@ -601,7 +601,7 @@ struct ti_i2c_desc {
struct ti_i2c_firmware_rec {
__u8 Ver_Major; // Firmware Major version number
__u8 Ver_Minor; // Firmware Minor version number
- __u8 Data[0]; // Download starts here
+ __u8 Data[]; // Download starts here
} __attribute__((packed));
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index ef23acc9b9ce..73075b9351c5 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -219,7 +219,7 @@ struct ti_write_data_bytes {
u8 bDataCounter;
__be16 wBaseAddrHi;
__be16 wBaseAddrLo;
- u8 bData[0];
+ u8 bData[];
} __packed;
struct ti_read_data_request {
@@ -234,7 +234,7 @@ struct ti_read_data_bytes {
__u8 bCmdCode;
__u8 bModuleId;
__u8 bErrorCode;
- __u8 bData[0];
+ __u8 bData[];
} __packed;
/* Interrupt struct */
diff --git a/include/linux/usb.h b/include/linux/usb.h
index ca1a5f1e1c5e..9f3c721c70dc 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -325,7 +325,7 @@ struct usb_interface_cache {
/* variable-length array of alternate settings for this interface,
* stored in no particular order */
- struct usb_host_interface altsetting[0];
+ struct usb_host_interface altsetting[];
};
#define ref_to_usb_interface_cache(r) \
container_of(r, struct usb_interface_cache, ref)
@@ -1589,7 +1589,7 @@ struct urb {
int error_count; /* (return) number of ISO errors */
void *context; /* (in) context for completion */
usb_complete_t complete; /* (in) completion routine */
- struct usb_iso_packet_descriptor iso_frame_desc[0];
+ struct usb_iso_packet_descriptor iso_frame_desc[];
/* (in) ISO ONLY */
};
diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h
index cb9900b34b67..ead8c9a47c6a 100644
--- a/include/linux/usb/audio-v2.h
+++ b/include/linux/usb/audio-v2.h
@@ -153,7 +153,7 @@ struct uac2_feature_unit_descriptor {
__u8 bSourceID;
/* bmaControls is actually u32,
* but u8 is needed for the hybrid parser */
- __u8 bmaControls[0]; /* variable length */
+ __u8 bmaControls[]; /* variable length */
} __attribute__((packed));
/* 4.7.2.10 Effect Unit Descriptor */
diff --git a/include/linux/usb/audio-v3.h b/include/linux/usb/audio-v3.h
index 6b708434b7f9..c69a6f2e6837 100644
--- a/include/linux/usb/audio-v3.h
+++ b/include/linux/usb/audio-v3.h
@@ -109,7 +109,7 @@ struct uac3_feature_unit_descriptor {
__u8 bSourceID;
/* bmaControls is actually u32,
* but u8 is needed for the hybrid parser */
- __u8 bmaControls[0]; /* variable length */
+ __u8 bmaControls[]; /* variable length */
/* wFeatureDescrStr omitted */
} __attribute__((packed));
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 124462d65eac..9411c08a5c7e 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -767,7 +767,7 @@ struct usb_gadget_strings {
struct usb_gadget_string_container {
struct list_head list;
- u8 *stash[0];
+ u8 *stash[];
};
/* put descriptor for string with that id into buf (buflen >= 256) */
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 712b2a603645..e12105ed3834 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -228,7 +228,7 @@ struct usb_hcd {
/* The HC driver's private data is stored at the end of
* this structure.
*/
- unsigned long hcd_priv[0]
+ unsigned long hcd_priv[]
__attribute__ ((aligned(sizeof(s64))));
};
diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h
index 79aab0065ec8..14ea197ce37f 100644
--- a/include/linux/usbdevice_fs.h
+++ b/include/linux/usbdevice_fs.h
@@ -69,7 +69,7 @@ struct usbdevfs_urb32 {
compat_int_t error_count;
compat_uint_t signr;
compat_caddr_t usercontext; /* unused */
- struct usbdevfs_iso_packet_desc iso_frame_desc[0];
+ struct usbdevfs_iso_packet_desc iso_frame_desc[];
};
struct usbdevfs_ioctl32 {
--
2.25.0
^ permalink raw reply related
* Re: [PATCH v3 01/20] scripts/git.orderfile: Display Cocci scripts before code modifications
From: Laurent Vivier @ 2020-02-20 13:10 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Peter Maydell, qemu-devel
Cc: Fam Zheng, Dmitry Fleytman, kvm, Michael S. Tsirkin, Jason Wang,
Gerd Hoffmann, Edgar E. Iglesias, Stefano Stabellini,
Matthew Rosato, qemu-block, David Hildenbrand, Halil Pasic,
Christian Borntraeger, Hervé Poussineau, Anthony Perard,
xen-devel, Aleksandar Rikalo, Richard Henderson, Thomas Huth,
Eduardo Habkost, Stefan Weil, Alistair Francis, Richard Henderson,
Paul Durrant, Eric Auger, qemu-s390x, qemu-arm,
Cédric Le Goater, John Snow, David Gibson, Igor Mitsyanko,
Cornelia Huck, Michael Walle, qemu-ppc, Paolo Bonzini
In-Reply-To: <20200220130548.29974-2-philmd@redhat.com>
On 20/02/2020 14:05, Philippe Mathieu-Daudé wrote:
> When we use a Coccinelle semantic script to do automatic
> code modifications, it makes sense to look at the semantic
> patch first.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> scripts/git.orderfile | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/scripts/git.orderfile b/scripts/git.orderfile
> index 1f747b583a..7cf22e0bf5 100644
> --- a/scripts/git.orderfile
> +++ b/scripts/git.orderfile
> @@ -22,6 +22,9 @@ Makefile*
> qapi/*.json
> qga/*.json
>
> +# semantic patches
> +*.cocci
> +
> # headers
> *.h
>
>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
^ permalink raw reply
* Re: [PATCH v7 1/5] btrfs: Introduce per-profile available space facility
From: Nikolay Borisov @ 2020-02-20 13:19 UTC (permalink / raw)
To: Qu Wenruo, Qu Wenruo, linux-btrfs; +Cc: Josef Bacik
In-Reply-To: <0f3b2eb2-1af4-13fb-8d9a-867dd7e68fb8@gmx.com>
On 20.02.20 г. 14:59 ч., Qu Wenruo wrote:
>
>
> On 2020/2/20 下午8:49, Nikolay Borisov wrote:
>> <snip>
>>
>>>
>>> Suggested-by: Josef Bacik <josef@toxicpanda.com>
>>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>>> ---
>>> fs/btrfs/volumes.c | 216 ++++++++++++++++++++++++++++++++++++++++-----
>>> fs/btrfs/volumes.h | 11 +++
>>> 2 files changed, 207 insertions(+), 20 deletions(-)
>>>
>>
<snip>
>>> + sort(devices_info, ndevs, sizeof(struct btrfs_device_info),
>>> + btrfs_cmp_device_info, NULL);
>>> + ndevs -= ndevs % raid_attr->devs_increment;
>>
>> nit: ndevs = rounddown(ndevs, raid_attr->devs_increment);
>
> IIRC round_down() can only be used when the alignment is power of 2.
>
> Don't forget we have RAID1C3 now.
Sure, but I'm referring to rounddown and not round_down :)
>
>> makes it more clear what's going on. Since you are working with at most
>> int it's not a problem for 32bits.
>>
>>
>>> + if (ndevs < raid_attr->devs_min)
>>> + return -ENOSPC;
>>> + if (raid_attr->devs_max)
>>> + ndevs = min(ndevs, (int)raid_attr->devs_max);
>>> + else
>>> + ndevs = min(ndevs, (int)BTRFS_MAX_DEVS(fs_info));
>>
>> Instead of casting simply use min_t(int, ndevs, BTRFS_MAX_DEVS...)
>
> That looks the same to me...
I guess it's a matter of preference so I will defer to David to decide.
>
>>
>>> +
>>> + /*
>>> + * Now allocate a virtual chunk using the unallocate space of the
>>
>> nit: missing d after 'unallocate'
>>
>>> + * device with the least unallocated space.
>>> + */
>>> + stripe_size = round_down(devices_info[ndevs - 1].total_avail,
>>> + fs_info->sectorsize);
>>> + if (stripe_size == 0)
>>> + return -ENOSPC;
>>
>> Isn't this check redundant - in the loop where you iterate the devices
>> you always ensure total_avail is at least a sector size, this guarantees
>> that stripe_size cannot be 0 at this point.
>>
>>> +
>>> + for (i = 0; i < ndevs; i++)
>>> + devices_info[i].dev->virtual_allocated += stripe_size;
>>> + *allocated = stripe_size * (ndevs - raid_attr->nparity) /
>>> + raid_attr->ncopies;
>>> + return 0;
>>> +}
>>> +
>>> +static int calc_one_profile_avail(struct btrfs_fs_info *fs_info,
>>> + enum btrfs_raid_types type,
>>> + u64 *result_ret)
>>> +{
>>> + struct btrfs_device_info *devices_info = NULL;
>>> + struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
>>> + struct btrfs_device *device;
>>> + u64 allocated;
>>> + u64 result = 0;
>>> + int ret = 0;
>>> +
>>
>> lockdep assert that chunk mutex is held since you access alloc_list.
>>
>>> + ASSERT(type >= 0 && type < BTRFS_NR_RAID_TYPES);
>>> +
>>> + /* Not enough devices, quick exit, just update the result */
>>> + if (fs_devices->rw_devices < btrfs_raid_array[type].devs_min)
>>> + goto out;
>>
>> You can directly return.
>>
>>> +
>>> + devices_info = kcalloc(fs_devices->rw_devices, sizeof(*devices_info),
>>> + GFP_NOFS);
>>> + if (!devices_info) {
>>> + ret = -ENOMEM;
>>> + goto out;
>>
>> Same here.
>>
>>> + }
>>> + /* Clear virtual chunk used space for each device */
>>> + list_for_each_entry(device, &fs_devices->alloc_list, dev_alloc_list)
>>> + device->virtual_allocated = 0;
>>> + while (ret == 0) {
>>> + ret = alloc_virtual_chunk(fs_info, devices_info, type,
>>> + &allocated);
>> The 'allocated' variable is used only in this loop so declare it in the
>> loop. Ideally we want variables to have the shortest possible lifecycle.
>>
>>> + if (ret == 0)
>>> + result += allocated;
>>> + }
>>
After the explanation on IRC I think it's better if this is written as:
while(!alloc_virtual_chunk(fs_info, devices_info, type, &allocated))
result += allocated
That way it's easier (at least for me) to spot you are "draining"
something. IN this case you try to allocate/simulate multiple
allocations to calculate the real available space.
>
> For this case, we must go several loops:
> Dev1: 10G
> Dev2: 5G
> Dev3: 5G
> Type: RAID1.
>
> The first loop will use 5G from dev1, 5G from dev2.
> Then the 2nd loop will use the remaining 5G from dev1, 5G from dev3.
>
> And that's the core problem per-profile available space system want to
> address.
>
<snip>
^ permalink raw reply
* [PATCH v3 14/20] hw/virtio: Let vhost_memory_map() use a boolean 'is_write' argument
From: Philippe Mathieu-Daudé @ 2020-02-20 13:05 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
Cc: Fam Zheng, Dmitry Fleytman, kvm, Michael S. Tsirkin, Jason Wang,
Gerd Hoffmann, Edgar E. Iglesias, Stefano Stabellini,
Matthew Rosato, qemu-block, David Hildenbrand, Halil Pasic,
Christian Borntraeger, Hervé Poussineau, Anthony Perard,
xen-devel, Aleksandar Rikalo, Richard Henderson,
Philippe Mathieu-Daudé, Laurent Vivier, Thomas Huth,
Eduardo Habkost, Stefan Weil, Alistair Francis, Richard Henderson,
Paul Durrant, Eric Auger, qemu-s390x, qemu-arm,
Cédric Le Goater, John Snow, David Gibson, Igor Mitsyanko,
Cornelia Huck, Michael Walle, qemu-ppc, Paolo Bonzini
In-Reply-To: <20200220130548.29974-1-philmd@redhat.com>
The 'is_write' argument is either 0 or 1.
Convert it to a boolean type.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/virtio/vhost.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 9edfadc81d..0d226dae10 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -294,7 +294,7 @@ static int vhost_dev_has_iommu(struct vhost_dev *dev)
}
static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr,
- hwaddr *plen, int is_write)
+ hwaddr *plen, bool is_write)
{
if (!vhost_dev_has_iommu(dev)) {
return cpu_physical_memory_map(addr, plen, is_write);
@@ -1012,21 +1012,21 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
vq->desc_size = s = l = virtio_queue_get_desc_size(vdev, idx);
vq->desc_phys = a;
- vq->desc = vhost_memory_map(dev, a, &l, 0);
+ vq->desc = vhost_memory_map(dev, a, &l, false);
if (!vq->desc || l != s) {
r = -ENOMEM;
goto fail_alloc_desc;
}
vq->avail_size = s = l = virtio_queue_get_avail_size(vdev, idx);
vq->avail_phys = a = virtio_queue_get_avail_addr(vdev, idx);
- vq->avail = vhost_memory_map(dev, a, &l, 0);
+ vq->avail = vhost_memory_map(dev, a, &l, false);
if (!vq->avail || l != s) {
r = -ENOMEM;
goto fail_alloc_avail;
}
vq->used_size = s = l = virtio_queue_get_used_size(vdev, idx);
vq->used_phys = a = virtio_queue_get_used_addr(vdev, idx);
- vq->used = vhost_memory_map(dev, a, &l, 1);
+ vq->used = vhost_memory_map(dev, a, &l, true);
if (!vq->used || l != s) {
r = -ENOMEM;
goto fail_alloc_used;
--
2.21.1
^ permalink raw reply related
* Re: [docs] "KBUILD_DEFCONFIG" description in kernel-dev manual seems wrong
From: rpjday @ 2020-02-20 13:19 UTC (permalink / raw)
To: docs
In-Reply-To: <CADkTA4OcvgoJE8ksdjFtQOLYnyaPRXGJXHeY3iDd9ooPD00Knw@mail.gmail.com>
Quoting Bruce Ashfield <bruce.ashfield@gmail.com>:
> On Thu, Feb 20, 2020 at 3:53 AM rpjday@crashcourse.ca
> <rpjday@crashcourse.ca> wrote:
>>
>>
>> in current kernel-dev manual, section on "in-tree" defconfig file:
>>
>> https://www.yoctoproject.org/docs/current/kernel-dev/kernel-dev.html#using-an-in-tree-defconfig-file
>>
>> the example given is:
>>
>> KBUILD_DEFCONFIG_common-pc ?=
>> "/home/scottrif/configfiles/my_defconfig_file"
>>
>> but that's not an "in-tree" file, is it? i thought that variable
>> referred to just the file name within an existing kernel source tree,
>> no? the processing in kernel-yocto.bbclass certainly suggests that:
>
> Correct. It is for defconfigs that are shipped with the kernel itself.
> The standard 'defconfig' in the SRC_URI covers other cases.
thought so … will fix.
rday
^ permalink raw reply
* [PATCH v5 5/6] toradex: MAINTAINERS: entries for new reST docs
From: Bin Meng @ 2020-02-20 13:19 UTC (permalink / raw)
To: u-boot
In-Reply-To: <20200212151433.9713-6-igor.opaniuk@gmail.com>
On Wed, Feb 12, 2020 at 11:14 PM Igor Opaniuk <igor.opaniuk@gmail.com> wrote:
>
> From: Igor Opaniuk <igor.opaniuk@toradex.com>
>
> Add entries for the newly created documentation files in reST
> format.
>
> Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>
> ---
>
> board/toradex/apalis-imx8/MAINTAINERS | 1 +
> board/toradex/colibri-imx8x/MAINTAINERS | 1 +
> board/toradex/colibri_imx7/MAINTAINERS | 1 +
> board/toradex/verdin-imx8mm/MAINTAINERS | 1 +
> 4 files changed, 4 insertions(+)
>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
^ permalink raw reply
* Re: [PATCH] mm: Fix possible PMD dirty bit lost in set_pmd_migration_entry()
From: Zi Yan @ 2020-02-20 13:18 UTC (permalink / raw)
To: Huang, Ying
Cc: Andrew Morton, linux-mm, linux-kernel, Kirill A . Shutemov,
Andrea Arcangeli, Michal Hocko, Vlastimil Babka
In-Reply-To: <20200220075220.2327056-1-ying.huang@intel.com>
[-- Attachment #1: Type: text/plain, Size: 2218 bytes --]
On 20 Feb 2020, at 2:52, Huang, Ying wrote:
> From: Huang Ying <ying.huang@intel.com>
>
> In set_pmd_migration_entry(), pmdp_invalidate() is used to change PMD
> atomically. But the PMD is read before that with an ordinary memory
> reading. If the THP (transparent huge page) is written between the
> PMD reading and pmdp_invalidate(), the PMD dirty bit may be lost, and
> cause data corruption. The race window is quite small, but still
> possible in theory, so need to be fixed.
>
> The race is fixed via using the return value of pmdp_invalidate() to
> get the original content of PMD, which is a read/modify/write atomic
> operation. So no THP writing can occur in between.
>
> The race has been introduced when the THP migration support is added
> in the commit 616b8371539a ("mm: thp: enable thp migration in generic
> path"). But this fix depends on the commit d52605d7cb30 ("mm: do not
> lose dirty and accessed bits in pmdp_invalidate()"). So it's easy to
> be backported after v4.16. But the race window is really small, so it
> may be fine not to backport the fix at all.
>
> Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Andrea Arcangeli <aarcange@redhat.com>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> ---
> mm/huge_memory.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 580098e115bd..b1e069e68189 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -3060,8 +3060,7 @@ void set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw,
> return;
>
> flush_cache_range(vma, address, address + HPAGE_PMD_SIZE);
> - pmdval = *pvmw->pmd;
> - pmdp_invalidate(vma, address, pvmw->pmd);
> + pmdval = pmdp_invalidate(vma, address, pvmw->pmd);
> if (pmd_dirty(pmdval))
> set_page_dirty(page);
> entry = make_migration_entry(page, pmd_write(pmdval));
> --
> 2.25.0
Looks good to me. Thanks.
Reviewed-by: Zi Yan <ziy@nvidia.com>
—
Best Regards,
Yan Zi
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 854 bytes --]
^ permalink raw reply
* [dpdk-dev] [PATCH] lib/cmdline_rdline: increase command line buf size
From: Wisam Jaddo @ 2020-02-20 13:18 UTC (permalink / raw)
To: dev, rasland, thomasm; +Cc: stable
The current size of buffer is not enough to fit all allowed items/actions,
thus it will block a lot of testing.
Cc: stable@dpdk.org
Signed-off-by: Wisam Jaddo <wisamm@mellanox.com>
---
lib/librte_cmdline/cmdline_rdline.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_cmdline/cmdline_rdline.h b/lib/librte_cmdline/cmdline_rdline.h
index d217029..8193e1d 100644
--- a/lib/librte_cmdline/cmdline_rdline.h
+++ b/lib/librte_cmdline/cmdline_rdline.h
@@ -39,7 +39,7 @@ extern "C" {
#endif
/* configuration */
-#define RDLINE_BUF_SIZE 512
+#define RDLINE_BUF_SIZE 2048
#define RDLINE_PROMPT_SIZE 32
#define RDLINE_VT100_BUF_SIZE 8
#define RDLINE_HISTORY_BUF_SIZE BUFSIZ
--
2.7.4
^ permalink raw reply related
* Re: [PATCH v3 01/22] hardirq/nmi: Allow nested nmi_enter()
From: Petr Mladek @ 2020-02-20 13:18 UTC (permalink / raw)
To: Peter Zijlstra
Cc: linux-kernel, linux-arch, rostedt, mingo, joel, gregkh, gustavo,
tglx, paulmck, josh, mathieu.desnoyers, jiangshanlai, luto,
tony.luck, frederic, dan.carpenter, mhiramat, Will Deacon,
Marc Zyngier, Michael Ellerman
In-Reply-To: <20200219150744.428764577@infradead.org>
On Wed 2020-02-19 15:47:25, Peter Zijlstra wrote:
> Since there are already a number of sites (ARM64, PowerPC) that
> effectively nest nmi_enter(), lets make the primitive support this
> before adding even more.
Reviewed-by: Petr Mladek <pmladek@suse.com> # for printk part
The rest looks good as well.
Best Regards,
Petr
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.