* Re: [PATCH 5/6] treewide: use kv[mz]alloc* rather than opencoded variants
From: Christian Borntraeger @ 2017-01-12 16:05 UTC (permalink / raw)
To: Michal Hocko, Andrew Morton
Cc: Vlastimil Babka, David Rientjes, Mel Gorman, Johannes Weiner,
Al Viro, linux-mm, LKML, Michal Hocko, Martin Schwidefsky,
Heiko Carstens, Herbert Xu, Anton Vorontsov, Colin Cross,
Kees Cook, Tony Luck, Rafael J. Wysocki, Ben Skeggs,
Kent Overstreet, Santosh Raspatur, Hariprasad S, Tariq
In-Reply-To: <20170112153717.28943-6-mhocko@kernel.org>
On 01/12/2017 04:37 PM, Michal Hocko wrote:
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 4f74511015b8..e6bbb33d2956 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -1126,10 +1126,7 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
> if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX)
> return -EINVAL;
>
> - keys = kmalloc_array(args->count, sizeof(uint8_t),
> - GFP_KERNEL | __GFP_NOWARN);
> - if (!keys)
> - keys = vmalloc(sizeof(uint8_t) * args->count);
> + keys = kvmalloc(args->count * sizeof(uint8_t), GFP_KERNEL);
> if (!keys)
> return -ENOMEM;
>
> @@ -1171,10 +1168,7 @@ static long kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
> if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX)
> return -EINVAL;
>
> - keys = kmalloc_array(args->count, sizeof(uint8_t),
> - GFP_KERNEL | __GFP_NOWARN);
> - if (!keys)
> - keys = vmalloc(sizeof(uint8_t) * args->count);
> + keys = kvmalloc(sizeof(uint8_t) * args->count, GFP_KERNEL);
> if (!keys)
> return -ENOMEM;
KVM/s390 parts
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
^ permalink raw reply
* Re: [PATCH net-next] cdc-ether: usbnet_cdc_zte_status() can be static
From: David Miller @ 2017-01-12 16:09 UTC (permalink / raw)
To: weiyj.lk; +Cc: oliver, weiyongjun1, linux-usb, netdev
In-Reply-To: <20170112134347.22793-1-weiyj.lk@gmail.com>
From: Wei Yongjun <weiyj.lk@gmail.com>
Date: Thu, 12 Jan 2017 13:43:47 +0000
> From: Wei Yongjun <weiyongjun1@huawei.com>
>
> Fixes the following sparse warning:
>
> drivers/net/usb/cdc_ether.c:469:6: warning:
> symbol 'usbnet_cdc_zte_status' was not declared. Should it be static?
>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Applied.
^ permalink raw reply
* Re: [PATCH v1 3/8] crypto:chcr- Fix key length for RFC4106
From: Herbert Xu @ 2017-01-12 16:09 UTC (permalink / raw)
To: Harsh Jain; +Cc: hariprasad, netdev, linux-crypto
In-Reply-To: <6d8e61299e051d51dacdb6bfd6c5e582b230027c.1483599449.git.harsh@chelsio.com>
On Fri, Jan 06, 2017 at 02:01:34PM +0530, Harsh Jain wrote:
> Check keylen before copying salt to avoid wrap around of Integer.
>
> Signed-off-by: Harsh Jain <harsh@chelsio.com>
> ---
> drivers/crypto/chelsio/chcr_algo.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
> index deec7c0..6c2dea3 100644
> --- a/drivers/crypto/chelsio/chcr_algo.c
> +++ b/drivers/crypto/chelsio/chcr_algo.c
> @@ -2194,8 +2194,8 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key,
> unsigned int ck_size;
> int ret = 0, key_ctx_size = 0;
>
> - if (get_aead_subtype(aead) ==
> - CRYPTO_ALG_SUB_TYPE_AEAD_RFC4106) {
> + if (get_aead_subtype(aead) == CRYPTO_ALG_SUB_TYPE_AEAD_RFC4106 &&
> + keylen > 3) {
> keylen -= 4; /* nonce/salt is present in the last 4 bytes */
> memcpy(aeadctx->salt, key + keylen, 4);
> }
We should return an error in this case.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: Correct method for initializing Pause and Asymmetrical Pause support in phy drivers
From: Andrew Lunn @ 2017-01-12 15:35 UTC (permalink / raw)
To: Marc Bertola; +Cc: netdev
In-Reply-To: <CAMqDo0XxvtjD+uJQeHJuSyN71zEEa5AB9YE1CUYK8wq2NGeAbQ@mail.gmail.com>
On Thu, Jan 12, 2017 at 10:21:29AM -0500, Marc Bertola wrote:
> Hello netdev list,
>
> I am currently investigating a problem related to Ethernet
> auto-negotiation of Pause and Asymmetrical Pause capabilities.
Hi Marc
Have you read:
commit 2fa3e25b454e267d8f55ee19c27be540495463e7
Author: Florian Fainelli <f.fainelli@gmail.com>
Date: Sun Nov 27 18:45:13 2016 -0800
Documentation: net: phy: Add a paragraph about pause frames/flow control
Describe that the Ethernet MAC controller is ultimately responsible for
dealing with proper pause frames/flow control advertisement and
enabling, and that it is therefore allowed to have it change
phydev->supported/advertising with SUPPORTED_Pause and
SUPPORTED_AsymPause.
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Andrew
^ permalink raw reply
* Re: [PATCH v1 0/8] crypto:chcr- Bug fixes
From: Herbert Xu @ 2017-01-12 16:14 UTC (permalink / raw)
To: Harsh Jain; +Cc: hariprasad, netdev, linux-crypto
In-Reply-To: <cover.1483599449.git.harsh@chelsio.com>
On Fri, Jan 06, 2017 at 02:01:31PM +0530, Harsh Jain wrote:
> The patch series is based on Herbert's cryptodev-2.6 tree.
> It include bug fixes.
>
> Atul Gupta (4):
> crypto:chcr-Change flow IDs
> crypto:chcr- Fix panic on dma_unmap_sg
> crypto:chcr- Check device is allocated before use
> crypto:chcr- Fix wrong typecasting
> Harsh Jain (4):
> crypto:chcr- Fix key length for RFC4106
> crypto:chcr- Use cipher instead of Block Cipher in gcm setkey
> crypto:chcr: Change cra_flags for cipher algos
> crypto:chcr- Change algo priority
When you resubmit this please split it into two series. Please
send the critical bug fixes (panic + key length + alloc check)
in one series separate from the others. This way I can push
them easily to the 4.10 tree.
Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: [PATCH/RFC net] ravb: do not use zero-length alighment DMA request
From: Sergei Shtylyov @ 2017-01-12 16:14 UTC (permalink / raw)
To: David Miller, horms; +Cc: magnus.damm, netdev, linux-renesas-soc
In-Reply-To: <20170112.110402.1123747824643306383.davem@davemloft.net>
On 01/12/2017 07:04 PM, David Miller wrote:
>> What I now see is that a few lines further up there is:
>>
>> if (skb_put_padto(skb, ETH_ZLEN))
>> goto drop;
>>
>> where ETH_ZLEN is 60.
>>
>> So I don't think we need to worry about skb->len being less than 60 and
>> this patch can be simplified to:
>>
>> if (len == 0)
>> len = 4;
>
> I'd say this might deserve a comment...
Sure. And the one better than the original "quick fix"... :-)
MBR, Sergei
^ permalink raw reply
* Re: Setting link down or up in software
From: Mason @ 2017-01-12 16:22 UTC (permalink / raw)
To: Andrew Lunn; +Cc: netdev, Mans Rullgard, Florian Fainelli, Thibaud Cornic
In-Reply-To: <20170112152856.GL13033@lunn.ch>
On 12/01/2017 16:28, Andrew Lunn wrote:
> Mason wrote:
>
>> Here's an example of "Link is Down" printed when I set link up:
>>
>> At [ 62.750220] I run ip link set dev eth0 down
>> Then leave the system idle for 10 minutes.
>> At [ 646.263041] I run ip link set dev eth0 up
>> At [ 647.364079] it prints "Link is Down"
>> At [ 649.417434] it prints "Link is Up - 1Gbps/Full - flow control rx/tx"
>
> Purely a guess, but when you up the interface, it starts auto
> negotiation. That often involves resetting the PHY. If the PHY has
> already once completed autoneg, e.g. because of the boot loader, it
> will be initially UP. The reset will put it DOWN, and then once
> autoneg is complete, it will be Up again.
>
> Pure guess. Go read the code and see if i'm write.
Thanks for giving me some food for thought, although the net framework
is far from easy to navigate. (So I'm not sure "go read the code" will
take me anywhere in the short term.)
Whatever the reason for the symptoms I'm seeing, some kind of race
condition must be involved, because it occurs randomly.
Regards.
^ permalink raw reply
* Re: [PATCH] fix itnull.cocci warnings
From: Herbert Xu @ 2017-01-12 16:26 UTC (permalink / raw)
To: Julia Lawall
Cc: Harsh Jain, hariprasad, netdev, linux-crypto, Atul Gupta,
kbuild-all
In-Reply-To: <alpine.DEB.2.20.1701071042410.2029@hadrien>
On Sat, Jan 07, 2017 at 10:46:17AM +0100, Julia Lawall wrote:
> The first argument to list_for_each_entry cannot be NULL.
>
> Generated by: scripts/coccinelle/iterators/itnull.cocci
>
> CC: Harsh Jain <harsh@chelsio.com>
> Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
> ---
>
> This code comes from the following git tree:
>
> url:
> https://github.com/0day-ci/linux/commits/Harsh-Jain/crypto-chcr-Bug-fixes/20170107-093356
> base:
> https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
> master
> In-Reply-To:
> <8e0086b56d8fb61637d179c32a09a1bca03c4186.1483599449.git.harsh@chelsio.com>
Harsh, please fold this patch into your series when you resubmit.
Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: Setting link down or up in software
From: Andrew Lunn @ 2017-01-12 16:27 UTC (permalink / raw)
To: Mason; +Cc: netdev, Mans Rullgard, Florian Fainelli, Thibaud Cornic
In-Reply-To: <75281de4-d50d-76fd-8de9-606001a4d93a@free.fr>
> Whatever the reason for the symptoms I'm seeing, some kind of race
> condition must be involved, because it occurs randomly.
The PHY is polled once a second for its status. So it would depend on
who fast autoneg happens if you see the down.
Andrew
^ permalink raw reply
* Re: [PATCH v2 7/7] uapi: export all headers under uapi directories
From: Jan Engelhardt @ 2017-01-12 16:28 UTC (permalink / raw)
To: Nicolas Dichtel
Cc: Christoph Hellwig, arnd, mmarek, linux-kbuild, linux-doc,
linux-kernel, linux-alpha, linux-snps-arc, linux-arm-kernel,
adi-buildroot-devel, linux-c6x-dev, linux-cris-kernel,
uclinux-h8-devel, linux-hexagon, linux-ia64, linux-m68k,
linux-metag, linux-mips, linux-am33-list, nios2-dev, openrisc,
linux-parisc, linuxppc-dev, linux-s390, linux-sh, sparclinux
In-Reply-To: <464a1323-4450-e563-ff59-9e6d57b75959@6wind.com>
On Thursday 2017-01-12 16:52, Nicolas Dichtel wrote:
>Le 09/01/2017 à 13:56, Christoph Hellwig a écrit :
>> On Fri, Jan 06, 2017 at 10:43:59AM +0100, Nicolas Dichtel wrote:
>>> Regularly, when a new header is created in include/uapi/, the developer
>>> forgets to add it in the corresponding Kbuild file. This error is usually
>>> detected after the release is out.
>>>
>>> In fact, all headers under uapi directories should be exported, thus it's
>>> useless to have an exhaustive list.
>>>
>>> After this patch, the following files, which were not exported, are now
>>> exported (with make headers_install_all):
>>
>> ... snip ...
>>
>>> linux/genwqe/.install
>>> linux/genwqe/..install.cmd
>>> linux/cifs/.install
>>> linux/cifs/..install.cmd
>>
>> I'm pretty sure these should not be exported!
>>
>Those files are created in every directory:
>$ find usr/include/ -name '\.\.install.cmd' | wc -l
>71
That still does not mean they should be exported.
Anything but headers (and directories as a skeleton structure) is maximally suspicious.
^ permalink raw reply
* Re: [PATCH v2 7/7] uapi: export all headers under uapi directories
From: Nicolas Dichtel @ 2017-01-12 16:32 UTC (permalink / raw)
To: Jan Engelhardt
Cc: Christoph Hellwig, arnd, mmarek, linux-kbuild, linux-doc,
linux-kernel, linux-alpha, linux-snps-arc, linux-arm-kernel,
adi-buildroot-devel, linux-c6x-dev, linux-cris-kernel,
uclinux-h8-devel, linux-hexagon, linux-ia64, linux-m68k,
linux-metag, linux-mips, linux-am33-list, nios2-dev, openrisc,
linux-parisc, linuxppc-dev, linux-s390, linux-sh, sparclinux
In-Reply-To: <alpine.LSU.2.20.1701121727180.19188@erq.vanv.qr>
Le 12/01/2017 à 17:28, Jan Engelhardt a écrit :
> On Thursday 2017-01-12 16:52, Nicolas Dichtel wrote:
>
>> Le 09/01/2017 à 13:56, Christoph Hellwig a écrit :
>>> On Fri, Jan 06, 2017 at 10:43:59AM +0100, Nicolas Dichtel wrote:
>>>> Regularly, when a new header is created in include/uapi/, the developer
>>>> forgets to add it in the corresponding Kbuild file. This error is usually
>>>> detected after the release is out.
>>>>
>>>> In fact, all headers under uapi directories should be exported, thus it's
>>>> useless to have an exhaustive list.
>>>>
>>>> After this patch, the following files, which were not exported, are now
>>>> exported (with make headers_install_all):
>>>
>>> ... snip ...
>>>
>>>> linux/genwqe/.install
>>>> linux/genwqe/..install.cmd
>>>> linux/cifs/.install
>>>> linux/cifs/..install.cmd
>>>
>>> I'm pretty sure these should not be exported!
>>>
>> Those files are created in every directory:
>> $ find usr/include/ -name '\.\.install.cmd' | wc -l
>> 71
>
> That still does not mean they should be exported.
>
> Anything but headers (and directories as a skeleton structure) is maximally suspicious.
>
What I was trying to say is that I export those directories like other are.
Removing those files is not related to that series.
Regards,
Nicolas
^ permalink raw reply
* Re: [PATCH] can: Fix kernel panic at security_sock_rcv_skb
From: Oliver Hartkopp @ 2017-01-12 16:33 UTC (permalink / raw)
To: Liu ShuoX
Cc: Eric Dumazet, linux-kernel, yanmin_zhang, shuox.liu, Zhang Yanmin,
He, Bo, Marc Kleine-Budde, David S. Miller,
open list:CAN NETWORK LAYER, open list:NETWORKING [GENERAL]
In-Reply-To: <1484226099.15816.25.camel@edumazet-glaptop3.roam.corp.google.com>
On 01/12/2017 02:01 PM, Eric Dumazet wrote:
> On Thu, 2017-01-12 at 09:22 +0100, Oliver Hartkopp wrote:
>> But my main concern is:
>>
>> The reason why can_rx_delete_receiver() was introduced was the need to
>> remove a huge number of receivers with can_rx_unregister().
>>
>> When you call synchronize_rcu() after each receiver removal this would
>> potentially lead to a big performance issue when e.g. closing CAN_RAW
>> sockets with a high number of receivers.
>>
>> So the idea was to remove/unlink the receiver hlist_del_rcu(&r->list)
>> and also kmem_cache_free(rcv_cache, r) by some rcu mechanism - so that
>> all elements are cleaned up by rcu at a later point.
>>
>> Is it possible that the problems emerge due to hlist_del_rcu(&r->list)
>> and you accidently fix it with your introduced synchronize_rcu()?
>
> I agree this patch does not fix the root cause.
>
> The main problem seems that the sockets themselves are not RCU
> protected.
>
> If CAN uses RCU for delivery, then sockets should be freed only after
> one RCU grace period.
>
> On recent kernels, following patch could help :
>
Thanks Eric!
@Liu ShuoX: Can you check if Eric's suggestion fixes the issue in your
setup?
Best regards,
Oliver
^ permalink raw reply
* Re: [PATCH/RFC v2 net-next] ravb: unmap descriptors when freeing rings
From: Sergei Shtylyov @ 2017-01-12 16:33 UTC (permalink / raw)
To: Simon Horman; +Cc: David Miller, Magnus Damm, netdev, linux-renesas-soc
In-Reply-To: <20170112131821.GA16060@verge.net.au>
On 01/12/2017 04:18 PM, Simon Horman wrote:
> ...
>
>>>> Here, it stop once an untransmitted buffer is encountered...
>>>
>>> Yes, I see that now.
>>>
>>> I wonder if we should:
>>>
>>> a) paramatise ravb_tx_free() so it may either clear all transmitted buffers
>>> (current behaviour) or all buffers (new behaviour).
>>> b) provide a different version of this loop in ravb_ring_free()
>>>
>>> What are your thoughts?
>>
>> I'm voting for (b).
>
> Ok, something like this?
>
> @@ -215,6 +225,30 @@ static void ravb_ring_free(struct net_device *ndev, int q)
> }
>
> if (priv->tx_ring[q]) {
> + for (; priv->cur_tx[q] - priv->dirty_tx[q] > 0; priv->dirty_tx[q]++) {
You're still copying the loop logic from ravb_tx_free() while we (I think)
need a simple loop over all the descriptor ring.
[...]
MBR, Sergei
^ permalink raw reply
* Re: [PATCH/RFC v2 net-next] ravb: unmap descriptors when freeing rings
From: Sergei Shtylyov @ 2017-01-12 16:37 UTC (permalink / raw)
To: Lino Sanfilippo, Simon Horman
Cc: David Miller, Magnus Damm, netdev, linux-renesas-soc
In-Reply-To: <d840eddd-f6a3-fe8c-dbaa-242c117b5274@marvell.com>
On 01/12/2017 04:23 PM, Lino Sanfilippo wrote:
>>>> +
>>>> + for (; priv->cur_tx[q] - priv->dirty_tx[q] > 0; priv->dirty_tx[q]++) {
>
> BTW: How can this work correctly when cur_tx wraps and dirty_tx is greater?
{cur|dirty}_tx never wrap.
> Regards,
> Lino
MBR, Sergei
^ permalink raw reply
* Re: [PATCH v1 3/8] crypto:chcr- Fix key length for RFC4106
From: Harsh Jain @ 2017-01-12 16:38 UTC (permalink / raw)
To: Herbert Xu; +Cc: hariprasad, netdev, linux-crypto
In-Reply-To: <20170112160959.GA19732@gondor.apana.org.au>
On 12-01-2017 21:39, Herbert Xu wrote:
> On Fri, Jan 06, 2017 at 02:01:34PM +0530, Harsh Jain wrote:
>> Check keylen before copying salt to avoid wrap around of Integer.
>>
>> Signed-off-by: Harsh Jain <harsh@chelsio.com>
>> ---
>> drivers/crypto/chelsio/chcr_algo.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
>> index deec7c0..6c2dea3 100644
>> --- a/drivers/crypto/chelsio/chcr_algo.c
>> +++ b/drivers/crypto/chelsio/chcr_algo.c
>> @@ -2194,8 +2194,8 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key,
>> unsigned int ck_size;
>> int ret = 0, key_ctx_size = 0;
>>
>> - if (get_aead_subtype(aead) ==
>> - CRYPTO_ALG_SUB_TYPE_AEAD_RFC4106) {
>> + if (get_aead_subtype(aead) == CRYPTO_ALG_SUB_TYPE_AEAD_RFC4106 &&
>> + keylen > 3) {
>> keylen -= 4; /* nonce/salt is present in the last 4 bytes */
>> memcpy(aeadctx->salt, key + keylen, 4);
>> }
> We should return an error in this case.
That case is already handled in next if condition.It will error out with -EINVAL in next condition.
if (keylen == AES_KEYSIZE_128) {
>
> Cheers,
^ permalink raw reply
* Re: [PATCH v2 8/8] crypto/testmgr: Allocate only the required output size for hash tests
From: Herbert Xu @ 2017-01-12 16:44 UTC (permalink / raw)
To: Andy Lutomirski
Cc: Daniel Borkmann, Netdev, LKML, Linux Crypto Mailing List,
Jason A. Donenfeld, Hannes Frederic Sowa, Alexei Starovoitov,
Eric Dumazet, Eric Biggers, Tom Herbert, David S. Miller,
Ard Biesheuvel
In-Reply-To: <890f4bdb28a1cf72f6b802b220b35ebaf0f76bb9.1484090585.git.luto@kernel.org>
On Tue, Jan 10, 2017 at 03:24:46PM -0800, Andy Lutomirski wrote:
> There are some hashes (e.g. sha224) that have some internal trickery
> to make sure that only the correct number of output bytes are
> generated. If something goes wrong, they could potentially overrun
> the output buffer.
>
> Make the test more robust by allocating only enough space for the
> correct output size so that memory debugging will catch the error if
> the output is overrun.
>
> Tested by intentionally breaking sha224 to output all 256
> internally-generated bits while running on KASAN.
>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* [PATCH iproute2] bridge: fdb: add state filter support
From: Nikolay Aleksandrov @ 2017-01-12 16:47 UTC (permalink / raw)
To: netdev; +Cc: roopa, stephen, purna, Nikolay Aleksandrov
This patch adds a new argument to the bridge fdb show command that allows
to filter by entry state.
Also update the man page to include all available show arguments.
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
bridge/fdb.c | 32 ++++++++++++++++++++++++++++++--
man/man8/bridge.8 | 10 +++++++++-
2 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/bridge/fdb.c b/bridge/fdb.c
index a91521776e99..a71a78f23b20 100644
--- a/bridge/fdb.c
+++ b/bridge/fdb.c
@@ -29,7 +29,7 @@
#include "rt_names.h"
#include "utils.h"
-static unsigned int filter_index, filter_vlan;
+static unsigned int filter_index, filter_vlan, filter_state;
json_writer_t *jw_global;
@@ -39,7 +39,7 @@ static void usage(void)
" [ self ] [ master ] [ use ] [ router ]\n"
" [ local | static | dynamic ] [ dst IPADDR ] [ vlan VID ]\n"
" [ port PORT] [ vni VNI ] [ via DEV ]\n");
- fprintf(stderr, " bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ] ]\n");
+ fprintf(stderr, " bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ] [ state STATE ] ]\n");
exit(-1);
}
@@ -63,6 +63,24 @@ static const char *state_n2a(unsigned int s)
return buf;
}
+static int state_a2n(unsigned int *s, const char *arg)
+{
+ if (matches(arg, "permanent") == 0)
+ *s = NUD_PERMANENT;
+ else if (matches(arg, "static") == 0 || matches(arg, "temp") == 0)
+ *s = NUD_NOARP;
+ else if (matches(arg, "stale") == 0)
+ *s = NUD_STALE;
+ else if (matches(arg, "reachable") == 0 || matches(arg, "dynamic") == 0)
+ *s = NUD_REACHABLE;
+ else if (strcmp(arg, "all") == 0)
+ *s = ~0;
+ else if (get_unsigned(s, arg, 0))
+ return -1;
+
+ return 0;
+}
+
static void start_json_fdb_flags_array(bool *fdb_flags)
{
if (*fdb_flags)
@@ -100,6 +118,9 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if (filter_index && filter_index != r->ndm_ifindex)
return 0;
+ if (filter_state && !(r->ndm_state & filter_state))
+ return 0;
+
parse_rtattr(tb, NDA_MAX, NDA_RTA(r),
n->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
@@ -310,6 +331,13 @@ static int fdb_show(int argc, char **argv)
if (filter_vlan)
duparg("vlan", *argv);
filter_vlan = atoi(*argv);
+ } else if (strcmp(*argv, "state") == 0) {
+ unsigned int state;
+
+ NEXT_ARG();
+ if (state_a2n(&state, *argv))
+ invarg("invalid state", *argv);
+ filter_state |= state;
} else {
if (matches(*argv, "help") == 0)
usage();
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 6617e188a384..9c5f855df72e 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -70,7 +70,15 @@ bridge \- show / manipulate bridge addresses and devices
.ti -8
.BR "bridge fdb" " [ " show " ] [ "
.B dev
-.IR DEV " ]"
+.IR DEV " ] [ "
+.B br
+.IR BRDEV " ] [ "
+.B brport
+.IR DEV " ] [ "
+.B vlan
+.IR VID " ] [ "
+.B state
+.IR STATE " ]"
.ti -8
.BR "bridge mdb" " { " add " | " del " } "
--
2.1.4
^ permalink raw reply related
* [PATCH net-next] ipv6: sr: static percpu allocation for hmac_ring
From: Eric Dumazet @ 2017-01-12 16:50 UTC (permalink / raw)
To: David Miller; +Cc: netdev, David Lebrun
From: Eric Dumazet <edumazet@google.com>
Current allocations are not NUMA aware, and lack proper
cleanup in case of error.
It is perfectly fine to use static per cpu allocations for 256 bytes
per cpu.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: David Lebrun <david.lebrun@uclouvain.be>
---
net/ipv6/seg6_hmac.c | 43 ++---------------------------------------
1 file changed, 3 insertions(+), 40 deletions(-)
diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c
index ef1c8a46e7aceee45b2044d4b4338dc3aed88807..6389bf3e9c9f28cdd3e30175f2880b74e099e273 100644
--- a/net/ipv6/seg6_hmac.c
+++ b/net/ipv6/seg6_hmac.c
@@ -45,7 +45,7 @@
#include <net/seg6_hmac.h>
#include <linux/random.h>
-static char * __percpu *hmac_ring;
+static DEFINE_PER_CPU(char [SEG6_HMAC_RING_SIZE], hmac_ring);
static int seg6_hmac_cmpfn(struct rhashtable_compare_arg *arg, const void *obj)
{
@@ -192,7 +192,7 @@ int seg6_hmac_compute(struct seg6_hmac_info *hinfo, struct ipv6_sr_hdr *hdr,
*/
local_bh_disable();
- ring = *this_cpu_ptr(hmac_ring);
+ ring = this_cpu_ptr(hmac_ring);
off = ring;
/* source address */
@@ -353,27 +353,6 @@ int seg6_push_hmac(struct net *net, struct in6_addr *saddr,
}
EXPORT_SYMBOL(seg6_push_hmac);
-static int seg6_hmac_init_ring(void)
-{
- int i;
-
- hmac_ring = alloc_percpu(char *);
-
- if (!hmac_ring)
- return -ENOMEM;
-
- for_each_possible_cpu(i) {
- char *ring = kzalloc(SEG6_HMAC_RING_SIZE, GFP_KERNEL);
-
- if (!ring)
- return -ENOMEM;
-
- *per_cpu_ptr(hmac_ring, i) = ring;
- }
-
- return 0;
-}
-
static int seg6_hmac_init_algo(void)
{
struct seg6_hmac_algo *algo;
@@ -422,16 +401,7 @@ static int seg6_hmac_init_algo(void)
int __init seg6_hmac_init(void)
{
- int ret;
-
- ret = seg6_hmac_init_ring();
- if (ret < 0)
- goto out;
-
- ret = seg6_hmac_init_algo();
-
-out:
- return ret;
+ return seg6_hmac_init_algo();
}
EXPORT_SYMBOL(seg6_hmac_init);
@@ -450,13 +420,6 @@ void seg6_hmac_exit(void)
struct seg6_hmac_algo *algo = NULL;
int i, alg_count, cpu;
- for_each_possible_cpu(i) {
- char *ring = *per_cpu_ptr(hmac_ring, i);
-
- kfree(ring);
- }
- free_percpu(hmac_ring);
-
alg_count = sizeof(hmac_algos) / sizeof(struct seg6_hmac_algo);
for (i = 0; i < alg_count; i++) {
algo = &hmac_algos[i];
^ permalink raw reply related
* Re: Correct method for initializing Pause and Asymmetrical Pause support in phy drivers
From: Marc Bertola @ 2017-01-12 16:52 UTC (permalink / raw)
To: Zefir Kurtisi; +Cc: netdev, Florian Fainelli, Timur Tabi
In-Reply-To: <68c58b10-1458-636e-a4a6-686a17ba743b@neratec.com>
Yes! This solution makes most sense, as Pause support is definitely on
the MAC side.
I thought this was not allowed because I was following instructions
from a stale copy of phy.txt -- I figured my copy was good because the
"last update" date at the top of the master file was the same. (It is
still 2008-04-08 -- see
https://github.com/torvalds/linux/blob/master/Documentation/networking/phy.txt)
Thank you very much for your swift response. This whole issue has been
very interesting to investigate. I'll take a look at Timur's cleanup
and respect that approach as I repair the older copy of kernel that I
am working with for this project.
^ permalink raw reply
* Re: [PATCH 5/6] treewide: use kv[mz]alloc* rather than opencoded variants
From: Ilya Dryomov @ 2017-01-12 16:54 UTC (permalink / raw)
To: Michal Hocko
Cc: Andrew Morton, Vlastimil Babka, David Rientjes, Mel Gorman,
Johannes Weiner, Al Viro, linux-mm, LKML, Michal Hocko,
Martin Schwidefsky, Heiko Carstens, Herbert Xu, Anton Vorontsov,
Colin Cross, Kees Cook, Tony Luck, Rafael J. Wysocki, Ben Skeggs,
Kent Overstreet, Santosh Raspatur, Hariprasad S, Tariq Toukan,
Yishai Hadas, Dan Williams <dan.
In-Reply-To: <20170112153717.28943-6-mhocko@kernel.org>
On Thu, Jan 12, 2017 at 4:37 PM, Michal Hocko <mhocko@kernel.org> wrote:
> From: Michal Hocko <mhocko@suse.com>
>
> There are many code paths opencoding kvmalloc. Let's use the helper
> instead. The main difference to kvmalloc is that those users are usually
> not considering all the aspects of the memory allocator. E.g. allocation
> requests < 64kB are basically never failing and invoke OOM killer to
> satisfy the allocation. This sounds too disruptive for something that
> has a reasonable fallback - the vmalloc. On the other hand those
> requests might fallback to vmalloc even when the memory allocator would
> succeed after several more reclaim/compaction attempts previously. There
> is no guarantee something like that happens though.
>
> This patch converts many of those places to kv[mz]alloc* helpers because
> they are more conservative.
>
> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Cc: Anton Vorontsov <anton@enomsg.org>
> Cc: Colin Cross <ccross@android.com>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Tony Luck <tony.luck@intel.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Cc: Kent Overstreet <kent.overstreet@gmail.com>
> Cc: Santosh Raspatur <santosh@chelsio.com>
> Cc: Hariprasad S <hariprasad@chelsio.com>
> Cc: Tariq Toukan <tariqt@mellanox.com>
> Cc: Yishai Hadas <yishaih@mellanox.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Oleg Drokin <oleg.drokin@intel.com>
> Cc: Andreas Dilger <andreas.dilger@intel.com>
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: David Sterba <dsterba@suse.com>
> Cc: "Yan, Zheng" <zyan@redhat.com>
> Cc: Ilya Dryomov <idryomov@gmail.com>
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Michal Hocko <mhocko@suse.com>
> ---
> arch/s390/kvm/kvm-s390.c | 10 ++-----
> crypto/lzo.c | 4 +--
> drivers/acpi/apei/erst.c | 8 ++---
> drivers/char/agp/generic.c | 8 +----
> drivers/gpu/drm/nouveau/nouveau_gem.c | 4 +--
> drivers/md/bcache/util.h | 12 ++------
> drivers/net/ethernet/chelsio/cxgb3/cxgb3_defs.h | 3 --
> drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c | 25 ++--------------
> drivers/net/ethernet/chelsio/cxgb3/l2t.c | 2 +-
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 31 ++++----------------
> drivers/net/ethernet/mellanox/mlx4/en_tx.c | 9 ++----
> drivers/net/ethernet/mellanox/mlx4/mr.c | 9 ++----
> drivers/nvdimm/dimm_devs.c | 5 +---
> .../staging/lustre/lnet/libcfs/linux/linux-mem.c | 11 +------
> drivers/xen/evtchn.c | 14 +--------
> fs/btrfs/ctree.c | 9 ++----
> fs/btrfs/ioctl.c | 9 ++----
> fs/btrfs/send.c | 27 ++++++-----------
> fs/ceph/file.c | 9 ++----
> fs/select.c | 5 +---
> fs/xattr.c | 27 ++++++-----------
> kernel/bpf/hashtab.c | 11 ++-----
> lib/iov_iter.c | 5 +---
> mm/frame_vector.c | 5 +---
> net/ipv4/inet_hashtables.c | 6 +---
> net/ipv4/tcp_metrics.c | 5 +---
> net/mpls/af_mpls.c | 5 +---
> net/netfilter/x_tables.c | 34 ++++++----------------
> net/netfilter/xt_recent.c | 5 +---
> net/sched/sch_choke.c | 5 +---
> net/sched/sch_fq_codel.c | 26 ++++-------------
> net/sched/sch_hhf.c | 33 ++++++---------------
> net/sched/sch_netem.c | 6 +---
> net/sched/sch_sfq.c | 6 +---
> security/keys/keyctl.c | 22 ++++----------
> 35 files changed, 96 insertions(+), 319 deletions(-)
>
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 4f74511015b8..e6bbb33d2956 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -1126,10 +1126,7 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
> if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX)
> return -EINVAL;
>
> - keys = kmalloc_array(args->count, sizeof(uint8_t),
> - GFP_KERNEL | __GFP_NOWARN);
> - if (!keys)
> - keys = vmalloc(sizeof(uint8_t) * args->count);
> + keys = kvmalloc(args->count * sizeof(uint8_t), GFP_KERNEL);
> if (!keys)
> return -ENOMEM;
>
> @@ -1171,10 +1168,7 @@ static long kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
> if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX)
> return -EINVAL;
>
> - keys = kmalloc_array(args->count, sizeof(uint8_t),
> - GFP_KERNEL | __GFP_NOWARN);
> - if (!keys)
> - keys = vmalloc(sizeof(uint8_t) * args->count);
> + keys = kvmalloc(sizeof(uint8_t) * args->count, GFP_KERNEL);
> if (!keys)
> return -ENOMEM;
>
> diff --git a/crypto/lzo.c b/crypto/lzo.c
> index 168df784da84..218567d717d6 100644
> --- a/crypto/lzo.c
> +++ b/crypto/lzo.c
> @@ -32,9 +32,7 @@ static void *lzo_alloc_ctx(struct crypto_scomp *tfm)
> {
> void *ctx;
>
> - ctx = kmalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL | __GFP_NOWARN);
> - if (!ctx)
> - ctx = vmalloc(LZO1X_MEM_COMPRESS);
> + ctx = kvmalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL);
> if (!ctx)
> return ERR_PTR(-ENOMEM);
>
> diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c
> index ec4f507b524f..a2898df61744 100644
> --- a/drivers/acpi/apei/erst.c
> +++ b/drivers/acpi/apei/erst.c
> @@ -513,7 +513,7 @@ static int __erst_record_id_cache_add_one(void)
> if (i < erst_record_id_cache.len)
> goto retry;
> if (erst_record_id_cache.len >= erst_record_id_cache.size) {
> - int new_size, alloc_size;
> + int new_size;
> u64 *new_entries;
>
> new_size = erst_record_id_cache.size * 2;
> @@ -524,11 +524,7 @@ static int __erst_record_id_cache_add_one(void)
> pr_warn(FW_WARN "too many record IDs!\n");
> return 0;
> }
> - alloc_size = new_size * sizeof(entries[0]);
> - if (alloc_size < PAGE_SIZE)
> - new_entries = kmalloc(alloc_size, GFP_KERNEL);
> - else
> - new_entries = vmalloc(alloc_size);
> + new_entries = kvmalloc(new_size * sizeof(entries[0]), GFP_KERNEL);
> if (!new_entries)
> return -ENOMEM;
> memcpy(new_entries, entries,
> diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
> index f002fa5d1887..bdf418cac8ef 100644
> --- a/drivers/char/agp/generic.c
> +++ b/drivers/char/agp/generic.c
> @@ -88,13 +88,7 @@ static int agp_get_key(void)
>
> void agp_alloc_page_array(size_t size, struct agp_memory *mem)
> {
> - mem->pages = NULL;
> -
> - if (size <= 2*PAGE_SIZE)
> - mem->pages = kmalloc(size, GFP_KERNEL | __GFP_NOWARN);
> - if (mem->pages == NULL) {
> - mem->pages = vmalloc(size);
> - }
> + mem->pages = kvmalloc(size, GFP_KERNEL);
> }
> EXPORT_SYMBOL(agp_alloc_page_array);
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
> index 201b52b750dd..77dd73ff126f 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
> @@ -568,9 +568,7 @@ u_memcpya(uint64_t user, unsigned nmemb, unsigned size)
>
> size *= nmemb;
>
> - mem = kmalloc(size, GFP_KERNEL | __GFP_NOWARN);
> - if (!mem)
> - mem = vmalloc(size);
> + mem = kvmalloc(size, GFP_KERNEL);
> if (!mem)
> return ERR_PTR(-ENOMEM);
>
> diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h
> index cf2cbc211d83..d00bcb64d3a8 100644
> --- a/drivers/md/bcache/util.h
> +++ b/drivers/md/bcache/util.h
> @@ -43,11 +43,7 @@ struct closure;
> (heap)->used = 0; \
> (heap)->size = (_size); \
> _bytes = (heap)->size * sizeof(*(heap)->data); \
> - (heap)->data = NULL; \
> - if (_bytes < KMALLOC_MAX_SIZE) \
> - (heap)->data = kmalloc(_bytes, (gfp)); \
> - if ((!(heap)->data) && ((gfp) & GFP_KERNEL)) \
> - (heap)->data = vmalloc(_bytes); \
> + (heap)->data = kvmalloc(_bytes, (gfp) & GFP_KERNEL); \
> (heap)->data; \
> })
>
> @@ -136,12 +132,8 @@ do { \
> \
> (fifo)->mask = _allocated_size - 1; \
> (fifo)->front = (fifo)->back = 0; \
> - (fifo)->data = NULL; \
> \
> - if (_bytes < KMALLOC_MAX_SIZE) \
> - (fifo)->data = kmalloc(_bytes, (gfp)); \
> - if ((!(fifo)->data) && ((gfp) & GFP_KERNEL)) \
> - (fifo)->data = vmalloc(_bytes); \
> + (fifo)->data = kvmalloc(_bytes, (gfp) & GFP_KERNEL); \
> (fifo)->data; \
> })
>
> diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_defs.h b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_defs.h
> index 920d918ed193..f04e81f33795 100644
> --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_defs.h
> +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_defs.h
> @@ -41,9 +41,6 @@
>
> #define VALIDATE_TID 1
>
> -void *cxgb_alloc_mem(unsigned long size);
> -void cxgb_free_mem(void *addr);
> -
> /*
> * Map an ATID or STID to their entries in the corresponding TID tables.
> */
> diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c
> index 76684dcb874c..606d4a3ade04 100644
> --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c
> +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c
> @@ -1152,27 +1152,6 @@ static void cxgb_redirect(struct dst_entry *old, struct dst_entry *new,
> }
>
> /*
> - * Allocate a chunk of memory using kmalloc or, if that fails, vmalloc.
> - * The allocated memory is cleared.
> - */
> -void *cxgb_alloc_mem(unsigned long size)
> -{
> - void *p = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
> -
> - if (!p)
> - p = vzalloc(size);
> - return p;
> -}
> -
> -/*
> - * Free memory allocated through t3_alloc_mem().
> - */
> -void cxgb_free_mem(void *addr)
> -{
> - kvfree(addr);
> -}
> -
> -/*
> * Allocate and initialize the TID tables. Returns 0 on success.
> */
> static int init_tid_tabs(struct tid_info *t, unsigned int ntids,
> @@ -1182,7 +1161,7 @@ static int init_tid_tabs(struct tid_info *t, unsigned int ntids,
> unsigned long size = ntids * sizeof(*t->tid_tab) +
> natids * sizeof(*t->atid_tab) + nstids * sizeof(*t->stid_tab);
>
> - t->tid_tab = cxgb_alloc_mem(size);
> + t->tid_tab = kvmalloc(size, GFP_KERNEL);
> if (!t->tid_tab)
> return -ENOMEM;
>
> @@ -1218,7 +1197,7 @@ static int init_tid_tabs(struct tid_info *t, unsigned int ntids,
>
> static void free_tid_maps(struct tid_info *t)
> {
> - cxgb_free_mem(t->tid_tab);
> + kvfree(t->tid_tab);
> }
>
> static inline void add_adapter(struct adapter *adap)
> diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.c b/drivers/net/ethernet/chelsio/cxgb3/l2t.c
> index 5f226eda8cd6..c9b06501ee0c 100644
> --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.c
> +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.c
> @@ -444,7 +444,7 @@ struct l2t_data *t3_init_l2t(unsigned int l2t_capacity)
> struct l2t_data *d;
> int i, size = sizeof(*d) + l2t_capacity * sizeof(struct l2t_entry);
>
> - d = cxgb_alloc_mem(size);
> + d = kvmalloc(size, GFP_KERNEL);
> if (!d)
> return NULL;
>
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> index 6f951877430b..671695cb3c15 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
> @@ -881,27 +881,6 @@ static int setup_sge_queues(struct adapter *adap)
> return err;
> }
>
> -/*
> - * Allocate a chunk of memory using kmalloc or, if that fails, vmalloc.
> - * The allocated memory is cleared.
> - */
> -void *t4_alloc_mem(size_t size)
> -{
> - void *p = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
> -
> - if (!p)
> - p = vzalloc(size);
> - return p;
> -}
> -
> -/*
> - * Free memory allocated through alloc_mem().
> - */
> -void t4_free_mem(void *addr)
> -{
> - kvfree(addr);
> -}
> -
> static u16 cxgb_select_queue(struct net_device *dev, struct sk_buff *skb,
> void *accel_priv, select_queue_fallback_t fallback)
> {
> @@ -1300,7 +1279,7 @@ static int tid_init(struct tid_info *t)
> max_ftids * sizeof(*t->ftid_tab) +
> ftid_bmap_size * sizeof(long);
>
> - t->tid_tab = t4_alloc_mem(size);
> + t->tid_tab = kvmalloc(size, GFP_KERNEL);
> if (!t->tid_tab)
> return -ENOMEM;
>
> @@ -3416,7 +3395,7 @@ static int adap_init0(struct adapter *adap)
> /* allocate memory to read the header of the firmware on the
> * card
> */
> - card_fw = t4_alloc_mem(sizeof(*card_fw));
> + card_fw = kvmalloc(sizeof(*card_fw), GFP_KERNEL);
>
> /* Get FW from from /lib/firmware/ */
> ret = request_firmware(&fw, fw_info->fw_mod_name,
> @@ -3436,7 +3415,7 @@ static int adap_init0(struct adapter *adap)
>
> /* Cleaning up */
> release_firmware(fw);
> - t4_free_mem(card_fw);
> + kvfree(card_fw);
>
> if (ret < 0)
> goto bye;
> @@ -4432,9 +4411,9 @@ static void free_some_resources(struct adapter *adapter)
> {
> unsigned int i;
>
> - t4_free_mem(adapter->l2t);
> + kvfree(adapter->l2t);
> t4_cleanup_sched(adapter);
> - t4_free_mem(adapter->tids.tid_tab);
> + kvfree(adapter->tids.tid_tab);
> cxgb4_cleanup_tc_u32(adapter);
> kfree(adapter->sge.egr_map);
> kfree(adapter->sge.ingr_map);
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> index 5886ad78058f..a5c1b815145e 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> @@ -70,13 +70,10 @@ int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv,
> ring->full_size = ring->size - HEADROOM - MAX_DESC_TXBBS;
>
> tmp = size * sizeof(struct mlx4_en_tx_info);
> - ring->tx_info = kmalloc_node(tmp, GFP_KERNEL | __GFP_NOWARN, node);
> + ring->tx_info = kvmalloc_node(tmp, GFP_KERNEL, node);
> if (!ring->tx_info) {
> - ring->tx_info = vmalloc(tmp);
> - if (!ring->tx_info) {
> - err = -ENOMEM;
> - goto err_ring;
> - }
> + err = -ENOMEM;
> + goto err_ring;
> }
>
> en_dbg(DRV, priv, "Allocated tx_info ring at addr:%p size:%d\n",
> diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c
> index 395b5463cfd9..82354fd0a87e 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/mr.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/mr.c
> @@ -115,12 +115,9 @@ static int mlx4_buddy_init(struct mlx4_buddy *buddy, int max_order)
>
> for (i = 0; i <= buddy->max_order; ++i) {
> s = BITS_TO_LONGS(1 << (buddy->max_order - i));
> - buddy->bits[i] = kcalloc(s, sizeof (long), GFP_KERNEL | __GFP_NOWARN);
> - if (!buddy->bits[i]) {
> - buddy->bits[i] = vzalloc(s * sizeof(long));
> - if (!buddy->bits[i])
> - goto err_out_free;
> - }
> + buddy->bits[i] = kvzalloc(s * sizeof(long), GFP_KERNEL);
> + if (!buddy->bits[i])
> + goto err_out_free;
> }
>
> set_bit(0, buddy->bits[buddy->max_order]);
> diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
> index 0eedc49e0d47..3bd332b167d9 100644
> --- a/drivers/nvdimm/dimm_devs.c
> +++ b/drivers/nvdimm/dimm_devs.c
> @@ -102,10 +102,7 @@ int nvdimm_init_config_data(struct nvdimm_drvdata *ndd)
> return -ENXIO;
> }
>
> - ndd->data = kmalloc(ndd->nsarea.config_size, GFP_KERNEL);
> - if (!ndd->data)
> - ndd->data = vmalloc(ndd->nsarea.config_size);
> -
> + ndd->data = kvmalloc(ndd->nsarea.config_size, GFP_KERNEL);
> if (!ndd->data)
> return -ENOMEM;
>
> diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c
> index a6a76a681ea9..8f638267e704 100644
> --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c
> +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c
> @@ -45,15 +45,6 @@ EXPORT_SYMBOL(libcfs_kvzalloc);
> void *libcfs_kvzalloc_cpt(struct cfs_cpt_table *cptab, int cpt, size_t size,
> gfp_t flags)
> {
> - void *ret;
> -
> - ret = kzalloc_node(size, flags | __GFP_NOWARN,
> - cfs_cpt_spread_node(cptab, cpt));
> - if (!ret) {
> - WARN_ON(!(flags & (__GFP_FS | __GFP_HIGH)));
> - ret = vmalloc_node(size, cfs_cpt_spread_node(cptab, cpt));
> - }
> -
> - return ret;
> + return kvzalloc_node(size, flags, cfs_cpt_spread_node(cptab, cpt));
> }
> EXPORT_SYMBOL(libcfs_kvzalloc_cpt);
> diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
> index 6890897a6f30..10f1ef582659 100644
> --- a/drivers/xen/evtchn.c
> +++ b/drivers/xen/evtchn.c
> @@ -87,18 +87,6 @@ struct user_evtchn {
> bool enabled;
> };
>
> -static evtchn_port_t *evtchn_alloc_ring(unsigned int size)
> -{
> - evtchn_port_t *ring;
> - size_t s = size * sizeof(*ring);
> -
> - ring = kmalloc(s, GFP_KERNEL);
> - if (!ring)
> - ring = vmalloc(s);
> -
> - return ring;
> -}
> -
> static void evtchn_free_ring(evtchn_port_t *ring)
> {
> kvfree(ring);
> @@ -334,7 +322,7 @@ static int evtchn_resize_ring(struct per_user_data *u)
> else
> new_size = 2 * u->ring_size;
>
> - new_ring = evtchn_alloc_ring(new_size);
> + new_ring = kvmalloc(new_size * sizeof(*new_ring), GFP_KERNEL);
> if (!new_ring)
> return -ENOMEM;
>
> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> index 146b2dc0d2cf..4fc9712d927d 100644
> --- a/fs/btrfs/ctree.c
> +++ b/fs/btrfs/ctree.c
> @@ -5391,13 +5391,10 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
> goto out;
> }
>
> - tmp_buf = kmalloc(fs_info->nodesize, GFP_KERNEL | __GFP_NOWARN);
> + tmp_buf = kvmalloc(fs_info->nodesize, GFP_KERNEL);
> if (!tmp_buf) {
> - tmp_buf = vmalloc(fs_info->nodesize);
> - if (!tmp_buf) {
> - ret = -ENOMEM;
> - goto out;
> - }
> + ret = -ENOMEM;
> + goto out;
> }
>
> left_path->search_commit_root = 1;
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 77dabfed3a5d..6f0b488c7428 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3547,12 +3547,9 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
> u64 last_dest_end = destoff;
>
> ret = -ENOMEM;
> - buf = kmalloc(fs_info->nodesize, GFP_KERNEL | __GFP_NOWARN);
> - if (!buf) {
> - buf = vmalloc(fs_info->nodesize);
> - if (!buf)
> - return ret;
> - }
> + buf = kvmalloc(fs_info->nodesize, GFP_KERNEL);
> + if (!buf)
> + return ret;
>
> path = btrfs_alloc_path();
> if (!path) {
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index d145ce804620..0621ca2a7b5d 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -6242,22 +6242,16 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
> sctx->clone_roots_cnt = arg->clone_sources_count;
>
> sctx->send_max_size = BTRFS_SEND_BUF_SIZE;
> - sctx->send_buf = kmalloc(sctx->send_max_size, GFP_KERNEL | __GFP_NOWARN);
> + sctx->send_buf = kvmalloc(sctx->send_max_size, GFP_KERNEL);
> if (!sctx->send_buf) {
> - sctx->send_buf = vmalloc(sctx->send_max_size);
> - if (!sctx->send_buf) {
> - ret = -ENOMEM;
> - goto out;
> - }
> + ret = -ENOMEM;
> + goto out;
> }
>
> - sctx->read_buf = kmalloc(BTRFS_SEND_READ_SIZE, GFP_KERNEL | __GFP_NOWARN);
> + sctx->read_buf = kvmalloc(BTRFS_SEND_READ_SIZE, GFP_KERNEL);
> if (!sctx->read_buf) {
> - sctx->read_buf = vmalloc(BTRFS_SEND_READ_SIZE);
> - if (!sctx->read_buf) {
> - ret = -ENOMEM;
> - goto out;
> - }
> + ret = -ENOMEM;
> + goto out;
> }
>
> sctx->pending_dir_moves = RB_ROOT;
> @@ -6278,13 +6272,10 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
> alloc_size = arg->clone_sources_count * sizeof(*arg->clone_sources);
>
> if (arg->clone_sources_count) {
> - clone_sources_tmp = kmalloc(alloc_size, GFP_KERNEL | __GFP_NOWARN);
> + clone_sources_tmp = kvmalloc(alloc_size, GFP_KERNEL);
> if (!clone_sources_tmp) {
> - clone_sources_tmp = vmalloc(alloc_size);
> - if (!clone_sources_tmp) {
> - ret = -ENOMEM;
> - goto out;
> - }
> + ret = -ENOMEM;
> + goto out;
> }
>
> ret = copy_from_user(clone_sources_tmp, arg->clone_sources,
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index 045d30d26624..78b18acf33ba 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -74,12 +74,9 @@ dio_get_pages_alloc(const struct iov_iter *it, size_t nbytes,
> align = (unsigned long)(it->iov->iov_base + it->iov_offset) &
> (PAGE_SIZE - 1);
> npages = calc_pages_for(align, nbytes);
> - pages = kmalloc(sizeof(*pages) * npages, GFP_KERNEL);
> - if (!pages) {
> - pages = vmalloc(sizeof(*pages) * npages);
> - if (!pages)
> - return ERR_PTR(-ENOMEM);
> - }
> + pages = kvmalloc(sizeof(*pages) * npages, GFP_KERNEL);
> + if (!pages)
> + return ERR_PTR(-ENOMEM);
ceph hunk looks fine:
Acked-by: Ilya Dryomov <idryomov@gmail.com>
However I noticed that in some cases you've dropped the zeroing part:
fq_codel_init() and hhf_zalloc() zeroed both k and v, and some others
were inconsistent and zeroed only k. Given that the fallback branch
was probably dead, I'd keep the k behaviour. Was that intentional?
Thanks,
Ilya
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply
* Re: [EXT] Re: [PATCH/RFC v2 net-next] ravb: unmap descriptors when freeing rings
From: Lino Sanfilippo @ 2017-01-12 16:55 UTC (permalink / raw)
To: Sergei Shtylyov, Simon Horman
Cc: David Miller, Magnus Damm, netdev, linux-renesas-soc
In-Reply-To: <08e00682-a8da-1483-b2d8-f58d32587fd6@cogentembedded.com>
Hi,
On 12.01.2017 17:37, Sergei Shtylyov wrote:
> External Email
>
> ----------------------------------------------------------------------
> On 01/12/2017 04:23 PM, Lino Sanfilippo wrote:
>
>>>>> +
>>>>> + for (; priv->cur_tx[q] - priv->dirty_tx[q] > 0; priv->dirty_tx[q]++) {
>>
>> BTW: How can this work correctly when cur_tx wraps and dirty_tx is greater?
>
> {cur|dirty}_tx never wrap.
>
Both values are 32 bit and AFAICS they are only incremented (and never reset or
decremented).
So what prevents them from wrapping every 2^32 processed tx descriptors? Am I missing
something?
Regards,
Lino
^ permalink raw reply
* Re: [PATCH 5/6] treewide: use kv[mz]alloc* rather than opencoded variants
From: Dan Williams @ 2017-01-12 17:00 UTC (permalink / raw)
To: Michal Hocko
Cc: Andrew Morton, Vlastimil Babka, David Rientjes, Mel Gorman,
Johannes Weiner, Al Viro, Linux MM, LKML, Michal Hocko,
Martin Schwidefsky, Heiko Carstens, Herbert Xu, Anton Vorontsov,
Colin Cross, Kees Cook, Tony Luck, Rafael J. Wysocki, Ben Skeggs,
Kent Overstreet, Santosh Raspatur, Hariprasad S, Tariq Toukan,
Yishai Hadas, Oleg Drokin <oleg.
In-Reply-To: <20170112153717.28943-6-mhocko@kernel.org>
On Thu, Jan 12, 2017 at 7:37 AM, Michal Hocko <mhocko@kernel.org> wrote:
> From: Michal Hocko <mhocko@suse.com>
>
> There are many code paths opencoding kvmalloc. Let's use the helper
> instead. The main difference to kvmalloc is that those users are usually
> not considering all the aspects of the memory allocator. E.g. allocation
> requests < 64kB are basically never failing and invoke OOM killer to
> satisfy the allocation. This sounds too disruptive for something that
> has a reasonable fallback - the vmalloc. On the other hand those
> requests might fallback to vmalloc even when the memory allocator would
> succeed after several more reclaim/compaction attempts previously. There
> is no guarantee something like that happens though.
>
> This patch converts many of those places to kv[mz]alloc* helpers because
> they are more conservative.
>
[..]
> Cc: Dan Williams <dan.j.williams@intel.com>
[..]
> drivers/nvdimm/dimm_devs.c | 5 +---
Acked-by: Dan Williams <dan.j.williams@intel.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply
* Re: [PATCH v1 3/8] crypto:chcr- Fix key length for RFC4106
From: Herbert Xu @ 2017-01-12 16:42 UTC (permalink / raw)
To: Harsh Jain; +Cc: hariprasad, netdev, linux-crypto
In-Reply-To: <648404c5-4234-7895-d478-858433b0d093@chelsio.com>
On Thu, Jan 12, 2017 at 10:08:46PM +0530, Harsh Jain wrote:
>
> That case is already handled in next if condition.It will error out with -EINVAL in next condition.
>
> if (keylen == AES_KEYSIZE_128) {
Good point. Please split the patches according to whether they
should go into 4.10/4.11 and then resubmit.
Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: To netlink or not to netlink, that is the question
From: Stephen Hemminger @ 2017-01-12 17:14 UTC (permalink / raw)
To: Jason A. Donenfeld; +Cc: Netdev
In-Reply-To: <CAHmME9pkktqOSUyTS_XhgC-CE4iqTv6UEA6w74kkm3xnBY8z9g@mail.gmail.com>
On Thu, 12 Jan 2017 14:01:07 +0100
"Jason A. Donenfeld" <Jason@zx2c4.com> wrote:
> Hey folks,
>
> A few months ago I switched away from using netlink in wireguard,
> preferring instead to use ioctl. I had come up against limitations in
> rtnetlink, and ioctl presented a straightforward hard to screw-up
> alternative. The very simple API is documented here:
> https://git.zx2c4.com/WireGuard/tree/src/uapi.h
>
> This works well, and I'm reluctant to change it, but as I do more
> complicated things, and as kernel submission time looms nearer, I'm
> kept up at night by the notion that maybe I ought to give netlink
> another chance. But how?
>
> For each wireguard interface, there are three types of structures for
> userspace to configure. There is one wgdevice for each interface. Each
> wgdevice has a variable amount (up to 2^16) of wgpeers. Each wgpeer
> has a variable amount (up to 2^16) of wgipmasks. I'd like an interface
> to get and set all of these at once, atomically.
>
> Presently, with the ioctl, I just have a simple get ioctl and a simple
> set ioctl. The set one passes a user space pointer, which is read
> incrementally in kernel space. The get one will first return how much
> userspace should allocate, and then when called again will write
> incrementally into a provided userspace buffer up to a passed-in
> maximum number of bytes. Very basic, I'm quite happy.
>
> When I had tried to do this priorly with netlink, I did it by defining
> changelink and fill_info in rtnl_link_ops. For changelink, I iterated
> through the netlink objects, and for fill_info, I filled in the skb
> with netlink objects. This was a bit more complex but basically
> worked. Except netlink skbs have a maximum size and are buffered,
> which means things broke entirely when trying to read or write logs of
> wgpeers or lots of wgipmasks. So, the meager interfaces afforded to me
> by rtnl_link_ops are insufficient. Doing anything beyond this, either
> by registering new rtnetlink messages, or by using generic netlink,
> seemed overwhelmingly complex and undesirable.
>
> So I'm wondering -- is there a good way to be doing this with netlink?
> Or am I right to stay with ioctl?
>
> Thanks,
> Jason
It is up to you but I doubt that code with new private ioctl's will be
accepted upstream. If you want full review then post for inclusion upstream.
If you just want to maintain it is a private fork, go ahead and do what
you want and suffer the consequences.
^ permalink raw reply
* [PATCH] ARM: dts: am57xx-beagle-x15: implement errata "Ethernet RGMII2 Limited to 10/100 Mbps"
From: Grygorii Strashko @ 2017-01-12 17:14 UTC (permalink / raw)
To: Tony Lindgren, Mugunthan V N
Cc: linux-omap, Sekhar Nori, netdev, Grygorii Strashko
According to errata i880 description the speed of Ethernet port 1 on AM572x
SoCs rev 1.1 shuld be limited to 10/100Mbps, because RGMII2 Switching
Characteristics are not compatible with 1000 Mbps operation [1].
The issue is fixed with Rev 2.0 silicon.
Hence, rework Beagle-X15 and Begale-X15-revb1 to use phy-handle instead of
phy_id and apply corresponding limitation to the Ethernet Phy 1.
[1] http://www.ti.com/lit/er/sprz429j/sprz429j.pdf
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
arch/arm/boot/dts/am57xx-beagle-x15-common.dtsi | 14 ++++++++++++--
arch/arm/boot/dts/am57xx-beagle-x15-revb1.dts | 5 +++++
arch/arm/boot/dts/am57xx-beagle-x15.dts | 5 +++++
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/am57xx-beagle-x15-common.dtsi b/arch/arm/boot/dts/am57xx-beagle-x15-common.dtsi
index 78bee26..0429fa0 100644
--- a/arch/arm/boot/dts/am57xx-beagle-x15-common.dtsi
+++ b/arch/arm/boot/dts/am57xx-beagle-x15-common.dtsi
@@ -421,19 +421,29 @@
<&dra7_pmx_core 0x3f8>;
};
+&davinci_mdio {
+ phy0: ethernet-phy@1 {
+ reg = <1>;
+ };
+
+ phy1: ethernet-phy@2 {
+ reg = <2>;
+ };
+};
+
&mac {
status = "okay";
dual_emac;
};
&cpsw_emac0 {
- phy_id = <&davinci_mdio>, <1>;
+ phy-handle = <&phy0>;
phy-mode = "rgmii";
dual_emac_res_vlan = <1>;
};
&cpsw_emac1 {
- phy_id = <&davinci_mdio>, <2>;
+ phy-handle = <&phy1>;
phy-mode = "rgmii";
dual_emac_res_vlan = <2>;
};
diff --git a/arch/arm/boot/dts/am57xx-beagle-x15-revb1.dts b/arch/arm/boot/dts/am57xx-beagle-x15-revb1.dts
index ca85570..39a92af 100644
--- a/arch/arm/boot/dts/am57xx-beagle-x15-revb1.dts
+++ b/arch/arm/boot/dts/am57xx-beagle-x15-revb1.dts
@@ -22,3 +22,8 @@
vmmc-supply = <&vdd_3v3>;
vmmc-aux-supply = <&ldo1_reg>;
};
+
+/* errata i880 "Ethernet RGMII2 Limited to 10/100 Mbps" */
+&phy1 {
+ max-speed = <100>;
+};
diff --git a/arch/arm/boot/dts/am57xx-beagle-x15.dts b/arch/arm/boot/dts/am57xx-beagle-x15.dts
index 8c66f2e..19a60a1 100644
--- a/arch/arm/boot/dts/am57xx-beagle-x15.dts
+++ b/arch/arm/boot/dts/am57xx-beagle-x15.dts
@@ -22,3 +22,8 @@
&mmc1 {
vmmc-supply = <&ldo1_reg>;
};
+
+/* errata i880 "Ethernet RGMII2 Limited to 10/100 Mbps" */
+&phy1 {
+ max-speed = <100>;
+};
--
2.10.1.dirty
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox